Mercurial > hg > nginx-tests
annotate proxy_cache_control.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | a095b971fbcc |
children |
rev | line source |
---|---|
1774
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for proxy headers Expires / Cache-Control / X-Accel-Expires. |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http proxy cache rewrite/)->plan(19); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 $t->write_file_expand('nginx.conf', <<'EOF'); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 %%TEST_GLOBALS%% |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 daemon off; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 events { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 http { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 %%TEST_GLOBALS_HTTP%% |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 proxy_cache_path %%TESTDIR%%/cache keys_zone=NAME:1m; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 server { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 listen 127.0.0.1:8080; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server_name localhost; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 add_header X-Cache-Status $upstream_cache_status; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 location / { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 proxy_pass http://127.0.0.1:8081; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 proxy_cache NAME; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 proxy_cache_background_update on; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 location /ignore { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 proxy_pass http://127.0.0.1:8081; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 proxy_cache NAME; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 proxy_ignore_headers Cache-Control Expires; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 proxy_ignore_headers X-Accel-Expires; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 server { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 listen 127.0.0.1:8081; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 server_name localhost; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 location /expires { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 add_header Expires "Thu, 31 Dec 2037 23:55:55 GMT"; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 return 204; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 location /cache-control { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 add_header Cache-Control max-age=60; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 return 204; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 location /x-accel-expires { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 add_header X-Accel-Expires 60; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 return 204; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 location /x-accel-expires-at { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 add_header X-Accel-Expires @60; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 return 204; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 location /x-accel-expires-duplicate { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 add_header X-Accel-Expires 60; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 add_header X-Accel-Expires 0; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 return 204; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 location /ignore { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 add_header Expires "Thu, 31 Dec 2037 23:55:55 GMT"; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 add_header Cache-Control max-age=60; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 add_header X-Accel-Expires 60; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 return 204; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 location /cache-control-before-expires { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 add_header Cache-Control max-age=60; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 add_header Expires "Thu, 01 Jan 1970 00:00:01 GMT"; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 return 204; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 location /cache-control-after-expires { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 add_header Expires "Thu, 01 Jan 1970 00:00:01 GMT"; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 add_header Cache-Control max-age=60; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 return 204; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 location /cache-control-no-cache-before-expires { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 add_header Cache-Control no-cache; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 add_header Expires "Thu, 31 Dec 2037 23:55:55 GMT"; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 return 204; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 location /cache-control-no-cache-after-expires { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 add_header Expires "Thu, 31 Dec 2037 23:55:55 GMT"; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 add_header Cache-Control no-cache; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 return 204; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 location /x-accel-expires-before { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 add_header X-Accel-Expires 60; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 add_header Expires "Thu, 01 Jan 1970 00:00:01 GMT"; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 add_header Cache-Control no-cache; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 return 204; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 location /x-accel-expires-after { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 add_header Expires "Thu, 01 Jan 1970 00:00:01 GMT"; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 add_header Cache-Control no-cache; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 add_header X-Accel-Expires 60; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 return 204; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 location /x-accel-expires-0-before { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 add_header X-Accel-Expires 0; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 add_header Cache-Control max-age=60; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 add_header Expires "Thu, 31 Dec 2037 23:55:55 GMT"; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 return 204; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 location /x-accel-expires-0-after { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 add_header Cache-Control max-age=60; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 add_header Expires "Thu, 31 Dec 2037 23:55:55 GMT"; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 add_header X-Accel-Expires 0; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 return 204; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 location /cache-control-no-cache-one { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 add_header Cache-Control "no-cache, max-age=60"; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 return 204; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 location /cache-control-no-cache-multi { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
158 add_header Cache-Control no-cache; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 add_header Cache-Control max-age=60; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
160 return 204; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
161 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
162 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 location /extension-before-x-accel-expires { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 add_header Cache-Control stale-while-revalidate=2145902155; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
165 add_header X-Accel-Expires @1; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 return 204; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
167 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 location /extension-after-x-accel-expires { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
170 add_header X-Accel-Expires @1; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 add_header Cache-Control stale-while-revalidate=2145902155; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 return 204; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
174 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 location /set-cookie { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
176 add_header Set-Cookie foo; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
177 add_header Expires "Thu, 01 Jan 1970 00:00:01 GMT"; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
178 add_header Cache-control max-age=60; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
179 return 204; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
180 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
181 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
182 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
183 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
184 EOF |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
185 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
186 $t->run(); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
187 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
188 ############################################################################### |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
189 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
190 # cache headers work |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
191 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
192 like(get('/expires'), qr/HIT/, 'expires'); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
193 like(get('/cache-control'), qr/HIT/, 'cache-control'); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
194 like(get('/x-accel-expires'), qr/HIT/, 'x-accel-expires'); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
195 like(get('/x-accel-expires-at'), qr/EXPIRED/, 'x-accel-expires at'); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
196 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
197 # the second header to disable cache is duplicate and ignored |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
198 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
199 like(get('/x-accel-expires-duplicate'), qr/HIT/, 'x-accel-expires duplicate'); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
200 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
201 # with cache headers ignored, the response will be fresh |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
202 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
203 like(get('/ignore'), qr/MISS/, 'cache headers ignored'); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
204 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
205 # Cache-Control is preferred over Expires |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
206 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
207 like(get('/cache-control-before-expires'), qr/HIT/, |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
208 'cache-control before expires'); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
209 like(get('/cache-control-after-expires'), qr/HIT/, |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
210 'cache-control after expires'); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
211 like(get('/cache-control-no-cache-before-expires'), qr/MISS/, |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
212 'cache-control no-cache before expires'); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
213 like(get('/cache-control-no-cache-after-expires'), qr/MISS/, |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
214 'cache-control no-cache after expires'); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
215 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
216 # X-Accel-Expires is preferred over both Cache-Control and Expires |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
217 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
218 like(get('/x-accel-expires-before'), qr/HIT/, 'x-accel-expires before'); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
219 like(get('/x-accel-expires-after'), qr/HIT/, 'x-accel-expires after'); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
220 like(get('/x-accel-expires-0-before'), qr/MISS/, 'x-accel-expires 0 before'); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
221 like(get('/x-accel-expires-0-after'), qr/MISS/, 'x-accel-expires 0 after'); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
222 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
223 # "Cache-Control: no-cache" disables caching, no matter of "max-age" |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
224 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
225 like(get('/cache-control-no-cache-one'), qr/MISS/, |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
226 'cache-control no-cache'); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
227 like(get('/cache-control-no-cache-multi'), qr/MISS/, |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
228 'cache-control no-cache multi line'); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
229 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
230 # Cache-Control extensions are preserved with X-Accel-Expires |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
231 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
232 like(get('/extension-before-x-accel-expires'), |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
233 qr/STALE/, 'cache-control extensions before x-accel-expires'); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
234 like(get('/extension-after-x-accel-expires'), |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
235 qr/STALE/, 'cache-control extensions after x-accel-expires'); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
236 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
237 # Set-Cookie is considered when caching with Cache-Control |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
238 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
239 like(get('/set-cookie'), qr/MISS/, 'set-cookie not cached'); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
240 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
241 ############################################################################### |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
242 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
243 sub get { |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
244 my ($uri) = @_; |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
245 http_get($uri); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
246 http_get($uri); |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
247 } |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
248 |
5a625ce0de34
Tests: added proxy cache tests with upstream cache headers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
249 ############################################################################### |