annotate proxy_cache_revalidate.t @ 531:679a7669ee71

Tests: no revalidation of a 404 cache entry.
author Sergey Kandaurov <pluknet@nginx.com>
date Sat, 28 Feb 2015 15:17:48 +0300
parents a61571a5f8df
children 907e89fba9c3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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';
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
17 use Test::Nginx qw/ :DEFAULT :gzip /;
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
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
24 plan(skip_all => 'win32') if $^O eq 'MSWin32';
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
25
530
a61571a5f8df Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents: 474
diff changeset
26 my $t = Test::Nginx->new()->has(qw/http proxy cache rewrite/)
353
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
27 ->write_file_expand('nginx.conf', <<'EOF');
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 %%TEST_GLOBALS%%
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 daemon off;
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 events {
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
34 }
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
35
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
36 http {
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
37 %%TEST_GLOBALS_HTTP%%
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
38
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
39 proxy_cache_path %%TESTDIR%%/cache levels=1:2
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
40 keys_zone=one:1m;
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 proxy_cache_revalidate on;
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
43
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
44 server {
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
45 listen 127.0.0.1:8080;
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
46 server_name localhost;
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
47
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
48 location / {
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
49 proxy_pass http://127.0.0.1:8081;
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
50 proxy_cache one;
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
51
531
679a7669ee71 Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents: 530
diff changeset
52 proxy_cache_valid 200 404 1s;
353
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 add_header X-Cache-Status $upstream_cache_status;
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 }
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
57
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
58 server {
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
59 listen 127.0.0.1:8081;
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
60 server_name localhost;
413
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
61
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
62 location / { }
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
63 location /etag/ {
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
64 proxy_pass http://127.0.0.1:8081/;
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
65 proxy_hide_header Last-Modified;
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
66 }
530
a61571a5f8df Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents: 474
diff changeset
67 location /201 {
a61571a5f8df Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents: 474
diff changeset
68 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
69 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
70 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
71 return 201;
a61571a5f8df Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents: 474
diff changeset
72 }
353
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 }
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
75
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
76 EOF
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
77
531
679a7669ee71 Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents: 530
diff changeset
78 my $d = $t->testdir();
679a7669ee71 Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents: 530
diff changeset
79
353
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
80 $t->write_file('t', 'SEE-THIS');
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
81 $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
82 $t->write_file('t3', 'SEE-THIS');
353
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
83
531
679a7669ee71 Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents: 530
diff changeset
84 $t->run()->plan(23);
353
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 ###############################################################################
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 # request documents and make sure they are cached
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
89
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
90 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
91 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
92
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
93 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
94 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
95
413
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
96 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
97 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
98
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
99 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
100 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
101
530
a61571a5f8df Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents: 474
diff changeset
102 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
103 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
104
531
679a7669ee71 Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents: 530
diff changeset
105 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
106
353
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
107 # wait for a while for cached responses to expire
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 select undef, undef, undef, 2.5;
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
110
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
111 # 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
112 # (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
113
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
114 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
115 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
116
531
679a7669ee71 Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents: 530
diff changeset
117 rename("$d/t3", "$d/t3_moved");
679a7669ee71 Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents: 530
diff changeset
118
679a7669ee71 Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents: 530
diff changeset
119 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
120
354
fb366c51eac6 Tests: reduce race in cache revalidate test.
Maxim Dounin <mdounin@mdounin.ru>
parents: 353
diff changeset
121 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
122 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
123
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
124 # 2nd document is recreated with a new content
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
125
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
126 $t->write_file('t2', 'NEW');
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
127 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
128 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
129
413
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
130 # the same for etag:
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
131 # 1st document isn't modified
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
132 # 2nd document is recreated
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
133
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
134 TODO: {
473
9a6e0ede4b92 Tests: adjusted proxy cache revalidate TODO.
Sergey Kandaurov <pluknet@nginx.com>
parents: 467
diff changeset
135 local $TODO = 'not yet' unless $t->has_version('1.7.7');
413
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
136
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
137 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
138 'etag revalidated');
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
139
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
140 }
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
141
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
142 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
143 'etag cached again');
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
144 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
145 'etag2 revalidate failed');
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
146 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
147 'etag2 new response cached');
f620d9529ed6 Tests: cache revalidate tests with ETag.
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
148
530
a61571a5f8df Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents: 474
diff changeset
149 # 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
150
a61571a5f8df Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents: 474
diff changeset
151 # 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
152 # 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
153 # 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
154
a61571a5f8df Tests: conditional requests only for cached 200/206 responses.
Sergey Kandaurov <pluknet@nginx.com>
parents: 474
diff changeset
155 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
156
531
679a7669ee71 Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents: 530
diff changeset
157 # 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
158
679a7669ee71 Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents: 530
diff changeset
159 select undef, undef, undef, 2.5;
679a7669ee71 Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents: 530
diff changeset
160
679a7669ee71 Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents: 530
diff changeset
161 # 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
162
679a7669ee71 Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents: 530
diff changeset
163 # 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
164 # 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
165 # 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
166 # 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
167 # (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
168 # 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
169 # 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
170 # 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
171
679a7669ee71 Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents: 530
diff changeset
172 rename("$d/t3_moved", "$d/t3");
679a7669ee71 Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents: 530
diff changeset
173
679a7669ee71 Tests: no revalidation of a 404 cache entry.
Sergey Kandaurov <pluknet@nginx.com>
parents: 530
diff changeset
174 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
175
353
19f58e91617a Tests: proxy cache revalidate tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
176 ###############################################################################