Mercurial > hg > nginx-tests
changeset 530:a61571a5f8df
Tests: conditional requests only for cached 200/206 responses.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 03 Mar 2015 21:04:51 +0300 |
parents | 42810c40ebb8 |
children | 679a7669ee71 |
files | proxy_cache_revalidate.t |
diffstat | 1 files changed, 19 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/proxy_cache_revalidate.t Wed Mar 04 16:53:10 2015 +0300 +++ b/proxy_cache_revalidate.t Tue Mar 03 21:04:51 2015 +0300 @@ -23,7 +23,7 @@ plan(skip_all => 'win32') if $^O eq 'MSWin32'; -my $t = Test::Nginx->new()->has(qw/http proxy cache/) +my $t = Test::Nginx->new()->has(qw/http proxy cache rewrite/) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -64,6 +64,12 @@ proxy_pass http://127.0.0.1:8081/; proxy_hide_header Last-Modified; } + location /201 { + add_header Last-Modified "Mon, 02 Mar 2015 17:20:58 GMT"; + add_header Cache-Control "max-age=1"; + add_header X-If-Modified-Since $http_if_modified_since; + return 201; + } } } @@ -72,7 +78,7 @@ $t->write_file('t', 'SEE-THIS'); $t->write_file('t2', 'SEE-THIS'); -$t->run()->plan(17); +$t->run()->plan(20); ############################################################################### @@ -90,6 +96,9 @@ like(http_get('/etag/t2'), qr/X-Cache-Status: MISS.*SEE/ms, 'etag2'); like(http_get('/etag/t2'), qr/X-Cache-Status: HIT.*SEE/ms, 'etag2 cached'); +like(http_get('/201'), qr/X-Cache-Status: MISS/, 'other status'); +like(http_get('/201'), qr/X-Cache-Status: HIT/, 'other status cached'); + # wait for a while for cached responses to expire select undef, undef, undef, 2.5; @@ -128,4 +137,12 @@ like(http_get('/etag/t2'), qr/X-Cache-Status: HIT.*NEW/ms, 'etag2 new response cached'); +# check that conditional requests are only used for 200/206 responses + +# d0ce06cb9be1 in 1.7.3 changed to ignore header filter's work to strip +# the Last-Modified header when storing non-200/206 in cache; +# 1573fc7875fa in 1.7.9 effectively turned it back. + +unlike(http_get('/201'), qr/X-If-Modified/, 'other status no revalidation'); + ###############################################################################