comparison proxy_cache_vary.t @ 1672:feb754918372

Tests: adjusted caching time for Vary tests with cold cache. Long nginx startup could result in cache entries prematurely expired due to "expires 2s;", e.g. when loading many dynamic modules.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 16 Apr 2021 20:20:26 +0300
parents e682d5ad3861
children 5ac6efbe5552
comparison
equal deleted inserted replaced
1671:e57bb4224131 1672:feb754918372
79 79
80 location / { 80 location / {
81 if ($args = "novary") { 81 if ($args = "novary") {
82 return 200 "the only variant\n"; 82 return 200 "the only variant\n";
83 } 83 }
84
85 add_header Vary $arg_vary;
86 add_header Xtra $arg_xtra;
87 } 84 }
88 85
89 location /asterisk { 86 location /asterisk {
90 gzip off; 87 gzip off;
91 add_header Vary "*"; 88 add_header Vary "*";
93 90
94 location /complex { 91 location /complex {
95 gzip off; 92 gzip off;
96 add_header Vary ",, Accept-encoding , ,"; 93 add_header Vary ",, Accept-encoding , ,";
97 } 94 }
95
96 location /cold {
97 expires max;
98 add_header Vary $arg_vary;
99 add_header Xtra $arg_xtra;
100 }
98 } 101 }
99 } 102 }
100 103
101 EOF 104 EOF
102 105
103 $t->write_file('index.html', 'SEE-THIS'); 106 $t->write_file('index.html', 'SEE-THIS');
104 $t->write_file('asterisk', 'SEE-THIS'); 107 $t->write_file('asterisk', 'SEE-THIS');
105 $t->write_file('complex', 'SEE-THIS'); 108 $t->write_file('complex', 'SEE-THIS');
109 $t->write_file('cold', 'SEE-THIS');
106 110
107 $t->run(); 111 $t->run();
108 112
109 ############################################################################### 113 ###############################################################################
110 114
254 # keep c->body_start when Vary changes (ticket #2029) 258 # keep c->body_start when Vary changes (ticket #2029)
255 259
256 # before 1.19.3, this prevented updating c->body_start of a main key 260 # before 1.19.3, this prevented updating c->body_start of a main key
257 # triggering "cache file .. has too long header" critical errors 261 # triggering "cache file .. has too long header" critical errors
258 262
259 like(get1('/?vary=x,y', 'x:1'), qr/MISS/, 'change first'); 263 get1('/cold?vary=z', 'z:1');
264 like(get1('/cold?vary=x,y', 'x:1'), qr/MISS/, 'change first');
260 265
261 TODO: { 266 TODO: {
262 local $TODO = 'not yet' unless $t->has_version('1.19.3'); 267 local $TODO = 'not yet' unless $t->has_version('1.19.3');
263 268
264 like(get1('/?vary=x,y', 'x:1'), qr/HIT/, 'change first cached'); 269 like(get1('/cold?vary=x,y', 'x:1'), qr/HIT/, 'change first cached');
265 270
266 } 271 }
267 272
268 like(get1('/?vary=x,y&xtra=1', 'x:2'), qr/MISS/, 'change second'); 273 like(get1('/cold?vary=x,y&xtra=1', 'x:2'), qr/MISS/, 'change second');
269 like(get1('/?vary=x,y&xtra=1', 'x:2'), qr/HIT/, 'change second cached'); 274 like(get1('/cold?vary=x,y&xtra=1', 'x:2'), qr/HIT/, 'change second cached');
270 275
271 $t->stop(); 276 $t->stop();
272 $t->run(); 277 $t->run();
273 278
274 # reset c->body_start when loading a secondary key variant 279 # reset c->body_start when loading a secondary key variant
275 280
276 # before 1.19.3, it was loaded using a variant stored with a main key 281 # before 1.19.3, it was loaded using a variant stored with a main key
277 # triggering "cache file .. has too long header" critical errors 282 # triggering "cache file .. has too long header" critical errors
278 283
279 like(get1('/?vary=x,y', 'x:1'), qr/HIT/, 'cold first'); 284 like(get1('/cold?vary=x,y', 'x:1'), qr/HIT/, 'cold first');
280 285
281 TODO: { 286 TODO: {
282 local $TODO = 'not yet' unless $t->has_version('1.19.3'); 287 local $TODO = 'not yet' unless $t->has_version('1.19.3');
283 288
284 like(get1('/?vary=x,y&xtra=1', 'x:2'), qr/HIT/, 'cold second'); 289 like(get1('/cold?vary=x,y&xtra=1', 'x:2'), qr/HIT/, 'cold second');
285 290
286 } 291 }
287 292
288 $t->stop(); 293 $t->stop();
289 294