Mercurial > hg > nginx-tests
annotate proxy_cache_revalidate.t @ 1857:da3889ba0b96
Tests: removed unneeded require from proxy_ssl_keepalive.t.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 18 May 2023 18:07:01 +0300 |
parents | fc3722dd8862 |
children |
rev | line source |
---|---|
353
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Tests for http proxy cache revalidation with conditional requests. |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 ############################################################################### |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 use warnings; |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use strict; |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 use Test::More; |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 BEGIN { use FindBin; chdir($FindBin::Bin); } |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 use lib 'lib'; |
1479
fc3722dd8862
Tests: removed unused gzip imports.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
17 use Test::Nginx; |
353
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 ############################################################################### |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 select STDERR; $| = 1; |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 select STDOUT; $| = 1; |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 |
1020
196d33c2bb45
Tests: removed TODO and try_run() checks for legacy versions.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
974
diff
changeset
|
24 my $t = Test::Nginx->new()->has(qw/http proxy cache rewrite/)->plan(23) |
353
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
25 ->write_file_expand('nginx.conf', <<'EOF'); |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 %%TEST_GLOBALS%% |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 daemon off; |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 events { |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 } |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 http { |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 %%TEST_GLOBALS_HTTP%% |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 proxy_cache_path %%TESTDIR%%/cache levels=1:2 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 keys_zone=one:1m; |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 proxy_cache_revalidate on; |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
43 listen 127.0.0.1:8080; |
353
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 server_name localhost; |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
45 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 location / { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
47 proxy_pass http://127.0.0.1:8081; |
353
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 proxy_cache one; |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 |
790
dfd214db57f4
Tests: adjusted proxy_cache_revalidate.t timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
574
diff
changeset
|
50 proxy_cache_valid 200 404 2s; |
353
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 add_header X-Cache-Status $upstream_cache_status; |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 } |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 } |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
57 listen 127.0.0.1:8081; |
353
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 server_name localhost; |
413
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
59 |
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
60 location / { } |
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
61 location /etag/ { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
62 proxy_pass http://127.0.0.1:8081/; |
413
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
63 proxy_hide_header Last-Modified; |
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
64 } |
530
a61571a5f8df
Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
474
diff
changeset
|
65 location /201 { |
a61571a5f8df
Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
474
diff
changeset
|
66 add_header Last-Modified "Mon, 02 Mar 2015 17:20:58 GMT"; |
a61571a5f8df
Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
474
diff
changeset
|
67 add_header Cache-Control "max-age=1"; |
a61571a5f8df
Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
474
diff
changeset
|
68 add_header X-If-Modified-Since $http_if_modified_since; |
a61571a5f8df
Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
474
diff
changeset
|
69 return 201; |
a61571a5f8df
Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
474
diff
changeset
|
70 } |
353
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 } |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 } |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 EOF |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
75 |
531
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
76 my $d = $t->testdir(); |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
77 |
353
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 $t->write_file('t', 'SEE-THIS'); |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
79 $t->write_file('t2', 'SEE-THIS'); |
531
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
80 $t->write_file('t3', 'SEE-THIS'); |
353
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
81 |
568
907e89fba9c3
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
531
diff
changeset
|
82 $t->run(); |
353
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
83 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 ############################################################################### |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 # request documents and make sure they are cached |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
87 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
88 like(http_get('/t'), qr/X-Cache-Status: MISS.*SEE/ms, 'request'); |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 like(http_get('/t'), qr/X-Cache-Status: HIT.*SEE/ms, 'request cached'); |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
90 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 like(http_get('/t2'), qr/X-Cache-Status: MISS.*SEE/ms, '2nd request'); |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 like(http_get('/t2'), qr/X-Cache-Status: HIT.*SEE/ms, '2nd request cached'); |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
93 |
413
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
94 like(http_get('/etag/t'), qr/X-Cache-Status: MISS.*SEE/ms, 'etag'); |
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
95 like(http_get('/etag/t'), qr/X-Cache-Status: HIT.*SEE/ms, 'etag cached'); |
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
96 |
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
97 like(http_get('/etag/t2'), qr/X-Cache-Status: MISS.*SEE/ms, 'etag2'); |
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
98 like(http_get('/etag/t2'), qr/X-Cache-Status: HIT.*SEE/ms, 'etag2 cached'); |
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
99 |
530
a61571a5f8df
Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
474
diff
changeset
|
100 like(http_get('/201'), qr/X-Cache-Status: MISS/, 'other status'); |
a61571a5f8df
Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
474
diff
changeset
|
101 like(http_get('/201'), qr/X-Cache-Status: HIT/, 'other status cached'); |
a61571a5f8df
Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
474
diff
changeset
|
102 |
531
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
103 like(http_get('/t3'), qr/SEE/, 'cache before 404'); |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
104 |
353
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
105 # wait for a while for cached responses to expire |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
106 |
790
dfd214db57f4
Tests: adjusted proxy_cache_revalidate.t timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
574
diff
changeset
|
107 select undef, undef, undef, 3.5; |
353
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
108 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
109 # 1st document isn't modified, and should be revalidated on first request |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
110 # (a 304 status code will appear in backend's logs), then cached again |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
112 like(http_get('/t'), qr/X-Cache-Status: REVALIDATED.*SEE/ms, 'revalidated'); |
413
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
113 like(http_get('/t'), qr/X-Cache-Status: HIT.*SEE/ms, 'cached again'); |
354
fb366c51eac6
Tests: reduce race in cache revalidate test.
Maxim Dounin <mdounin@mdounin.ru>
parents:
353
diff
changeset
|
114 |
531
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
115 rename("$d/t3", "$d/t3_moved"); |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
116 |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
117 like(http_get('/t3'), qr/ 404 /, 'cache 404 response'); |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
118 |
354
fb366c51eac6
Tests: reduce race in cache revalidate test.
Maxim Dounin <mdounin@mdounin.ru>
parents:
353
diff
changeset
|
119 select undef, undef, undef, 0.1; |
467
43e05ac6c23c
Tests: the read_file function added in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents:
413
diff
changeset
|
120 like($t->read_file('access.log'), qr/ 304 /, 'not modified'); |
353
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
121 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
122 # 2nd document is recreated with a new content |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
123 |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
124 $t->write_file('t2', 'NEW'); |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
125 like(http_get('/t2'), qr/X-Cache-Status: EXPIRED.*NEW/ms, 'revalidate failed'); |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
126 like(http_get('/t2'), qr/X-Cache-Status: HIT.*NEW/ms, 'new response cached'); |
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
127 |
413
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
128 # the same for etag: |
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
129 # 1st document isn't modified |
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
130 # 2nd document is recreated |
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
131 |
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
132 like(http_get('/etag/t'), qr/X-Cache-Status: REVALIDATED.*SEE/ms, |
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
133 'etag revalidated'); |
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
134 like(http_get('/etag/t'), qr/X-Cache-Status: HIT.*SEE/ms, |
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
135 'etag cached again'); |
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
136 like(http_get('/etag/t2'), qr/X-Cache-Status: EXPIRED.*NEW/ms, |
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
137 'etag2 revalidate failed'); |
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
138 like(http_get('/etag/t2'), qr/X-Cache-Status: HIT.*NEW/ms, |
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
139 'etag2 new response cached'); |
f620d9529ed6
Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
140 |
530
a61571a5f8df
Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
474
diff
changeset
|
141 # check that conditional requests are only used for 200/206 responses |
a61571a5f8df
Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
474
diff
changeset
|
142 |
a61571a5f8df
Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
474
diff
changeset
|
143 # d0ce06cb9be1 in 1.7.3 changed to ignore header filter's work to strip |
a61571a5f8df
Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
474
diff
changeset
|
144 # the Last-Modified header when storing non-200/206 in cache; |
a61571a5f8df
Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
474
diff
changeset
|
145 # 1573fc7875fa in 1.7.9 effectively turned it back. |
a61571a5f8df
Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
474
diff
changeset
|
146 |
a61571a5f8df
Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
474
diff
changeset
|
147 unlike(http_get('/201'), qr/X-If-Modified/, 'other status no revalidation'); |
a61571a5f8df
Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents:
474
diff
changeset
|
148 |
531
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
149 # wait for a while for a cached 404 response to expire |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
150 |
790
dfd214db57f4
Tests: adjusted proxy_cache_revalidate.t timeouts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
574
diff
changeset
|
151 select undef, undef, undef, 3.5; |
531
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
152 |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
153 # check that conditional requests are not used to revalidate 404 response |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
154 |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
155 # before fd283aa92e04 introduced in 1.7.7, this test passed by chance because |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
156 # of the If-Modified-Since header that was sent with Epoch in revalidation |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
157 # of responses cached without the Last-Modified header; |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
158 # fd283aa92e04 leaved (an legitimate) successful revalidation of 404 by ETag |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
159 # (introduced by 44b9ab7752e3 in 1.7.3), which caused the test to fail; |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
160 # 1573fc7875fa in 1.7.9 changed to not revalidate non-200/206 responses but |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
161 # leaked Last-Modified and ETag into 404 inherited from stale 200/206 response; |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
162 # 174512857ccf in 1.7.11 fixed the leak and allowed the test to pass. |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
163 |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
164 rename("$d/t3_moved", "$d/t3"); |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
165 |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
166 like(http_get('/t3'), qr/SEE/, 'no 404 revalidation after stale 200'); |
679a7669ee71
Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents:
530
diff
changeset
|
167 |
353
19f58e91617a
Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
168 ############################################################################### |