Mercurial > hg > nginx-tests
comparison proxy_cache_use_stale.t @ 1414:f5b18471e17a
Tests: proxy cache background update with regex captures.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 11 Dec 2018 16:10:33 +0300 |
parents | aaaa8a40250b |
children | 144c6ce732e4 |
comparison
equal
deleted
inserted
replaced
1413:215f3357034b | 1414:f5b18471e17a |
---|---|
78 | 78 |
79 location /t5.html { | 79 location /t5.html { |
80 proxy_pass http://127.0.0.1:8081/t.html; | 80 proxy_pass http://127.0.0.1:8081/t.html; |
81 | 81 |
82 proxy_cache_background_update off; | 82 proxy_cache_background_update off; |
83 } | |
84 | |
85 location ~ /(reg)(?P<name>exp).html { | |
86 proxy_pass http://127.0.0.1:8081/$1$name.html; | |
87 | |
88 proxy_cache_background_update on; | |
83 } | 89 } |
84 | 90 |
85 location /updating/ { | 91 location /updating/ { |
86 proxy_pass http://127.0.0.1:8081/; | 92 proxy_pass http://127.0.0.1:8081/; |
87 | 93 |
141 $t->write_file('t7.html', 'SEE-THIS' x 1024); | 147 $t->write_file('t7.html', 'SEE-THIS' x 1024); |
142 $t->write_file('t9.html', 'SEE-THIS' x 1024); | 148 $t->write_file('t9.html', 'SEE-THIS' x 1024); |
143 $t->write_file('ssi.html', 'xxx <!--#include virtual="/t9.html" --> xxx'); | 149 $t->write_file('ssi.html', 'xxx <!--#include virtual="/t9.html" --> xxx'); |
144 $t->write_file('escape.html', 'SEE-THIS'); | 150 $t->write_file('escape.html', 'SEE-THIS'); |
145 $t->write_file('escape html', 'SEE-THIS'); | 151 $t->write_file('escape html', 'SEE-THIS'); |
146 | 152 $t->write_file('regexp.html', 'SEE-THIS'); |
147 $t->run()->plan(33); | 153 |
154 $t->run()->plan(35); | |
148 | 155 |
149 ############################################################################### | 156 ############################################################################### |
150 | 157 |
151 like(get('/t.html', 'max-age=1, stale-if-error=5'), qr/MISS/, 'stale-if-error'); | 158 like(get('/t.html', 'max-age=1, stale-if-error=5'), qr/MISS/, 'stale-if-error'); |
152 like(http_get('/t.html?e=1'), qr/HIT/, 's-i-e - cached'); | 159 like(http_get('/t.html?e=1'), qr/HIT/, 's-i-e - cached'); |
165 get('/updating/t.html', 'max-age=1'); | 172 get('/updating/t.html', 'max-age=1'); |
166 get('/updating/t2.html', 'max-age=1, stale-while-revalidate=2'); | 173 get('/updating/t2.html', 'max-age=1, stale-while-revalidate=2'); |
167 get('/t8.html', 'stale-while-revalidate=10'); | 174 get('/t8.html', 'stale-while-revalidate=10'); |
168 get('/escape.htm%6C', 'max-age=1, stale-while-revalidate=10'); | 175 get('/escape.htm%6C', 'max-age=1, stale-while-revalidate=10'); |
169 get('/escape html', 'max-age=1, stale-while-revalidate=10'); | 176 get('/escape html', 'max-age=1, stale-while-revalidate=10'); |
177 get('/regexp.html', 'max-age=1, stale-while-revalidate=10'); | |
170 | 178 |
171 sleep 2; | 179 sleep 2; |
172 | 180 |
173 like(http_get('/t.html?e=1'), qr/STALE/, 's-i-e - stale'); | 181 like(http_get('/t.html?e=1'), qr/STALE/, 's-i-e - stale'); |
174 like(http_get('/tt.html?e=1'), qr/STALE/, 's-i-e - stale 2'); | 182 like(http_get('/tt.html?e=1'), qr/STALE/, 's-i-e - stale 2'); |
183 like(http_get('/t4.html'), qr/HIT/, 's-w-r - unconditional revalidated'); | 191 like(http_get('/t4.html'), qr/HIT/, 's-w-r - unconditional revalidated'); |
184 | 192 |
185 like(http_get('/t5.html?e=1'), qr/STALE/, | 193 like(http_get('/t5.html?e=1'), qr/STALE/, |
186 's-w-r - foreground revalidate error'); | 194 's-w-r - foreground revalidate error'); |
187 like(http_get('/t5.html'), qr/REVALIDATED/, 's-w-r - foreground revalidated'); | 195 like(http_get('/t5.html'), qr/REVALIDATED/, 's-w-r - foreground revalidated'); |
196 | |
197 # proxy_pass to regular expression with named and positional captures | |
198 | |
199 like(http_get('/regexp.html'), qr/STALE/, 's-w-r - regexp background update'); | |
200 | |
201 TODO: { | |
202 local $TODO = 'not yet' unless $t->has_version('1.15.8'); | |
203 | |
204 like(http_get('/regexp.html'), qr/HIT/, 's-w-r - regexp revalidated'); | |
205 | |
206 } | |
188 | 207 |
189 # UPDATING while s-w-r | 208 # UPDATING while s-w-r |
190 | 209 |
191 $t->write_file('t6.html', 'SEE-THAT'); | 210 $t->write_file('t6.html', 'SEE-THAT'); |
192 | 211 |