Mercurial > hg > nginx-tests
annotate proxy_cache_use_stale.t @ 1606:e4e0695552ed
Tests: fixed stream_proxy_ssl_conf_command.t.
The stream_proxy_ssl_conf_command.t test used stream return module
to return the response. Since this ignores actual request, but the
perl test code used http_get(). This might result in the request being
sent after the response is returned and the connection closed by the server,
resulting in RST being generated and no response seen by the client at all.
Fix is to use "stream(...)->read()" instead of http_get(), so
no request is sent at all, eliminating possibility of RST being
generated.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 10 Nov 2020 05:03:29 +0300 |
parents | 17b227c271a2 |
children | 5ac6efbe5552 |
rev | line source |
---|---|
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for http proxy cache, proxy_cache_use_stale. |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
1178
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
15 use IO::Select; |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
16 |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 BEGIN { use FindBin; chdir($FindBin::Bin); } |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use lib 'lib'; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 use Test::Nginx qw/ :DEFAULT http_end /; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 ############################################################################### |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDERR; $| = 1; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 select STDOUT; $| = 1; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
1178
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
27 my $t = Test::Nginx->new()->has(qw/http proxy cache rewrite limit_req ssi/) |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 ->write_file_expand('nginx.conf', <<'EOF'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 daemon off; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 events { |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 } |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 http { |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 %%TEST_GLOBALS_HTTP%% |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 proxy_cache_path %%TESTDIR%%/cache levels=1:2 keys_zone=NAME:1m; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 |
1412
aaaa8a40250b
Tests: adjusted proxy_cache_use_stale.t for slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
42 limit_req_zone $binary_remote_addr zone=one:1m rate=10r/m; |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 server { |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 listen 127.0.0.1:8080; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 server_name localhost; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 |
1178
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
48 location /ssi.html { |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
49 ssi on; |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
50 sendfile_max_chunk 4k; |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
51 } |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
52 |
1256
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
53 location /escape { |
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
54 proxy_pass http://127.0.0.1:8081; |
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
55 proxy_cache NAME; |
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
56 proxy_cache_background_update on; |
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
57 add_header X-Cache-Status $upstream_cache_status; |
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
58 } |
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
59 |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 location / { |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 proxy_pass http://127.0.0.1:8081; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 proxy_cache NAME; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 proxy_cache_key $uri; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 proxy_cache_revalidate on; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 proxy_cache_background_update on; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 add_header X-Cache-Status $upstream_cache_status; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 location /t4.html { |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 proxy_pass http://127.0.0.1:8081/t.html; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 proxy_cache_revalidate off; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 } |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 location /t5.html { |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 proxy_pass http://127.0.0.1:8081/t.html; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 proxy_cache_background_update off; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 } |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 |
1414
f5b18471e17a
Tests: proxy cache background update with regex captures.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1412
diff
changeset
|
85 location ~ /(reg)(?P<name>exp).html { |
f5b18471e17a
Tests: proxy cache background update with regex captures.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1412
diff
changeset
|
86 proxy_pass http://127.0.0.1:8081/$1$name.html; |
f5b18471e17a
Tests: proxy cache background update with regex captures.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1412
diff
changeset
|
87 |
f5b18471e17a
Tests: proxy cache background update with regex captures.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1412
diff
changeset
|
88 proxy_cache_background_update on; |
f5b18471e17a
Tests: proxy cache background update with regex captures.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1412
diff
changeset
|
89 } |
f5b18471e17a
Tests: proxy cache background update with regex captures.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1412
diff
changeset
|
90 |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 location /updating/ { |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 proxy_pass http://127.0.0.1:8081/; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 proxy_cache_use_stale updating; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 } |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 |
1178
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
97 location /t7.html { |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
98 proxy_pass http://127.0.0.1:8081; |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
99 |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
100 sendfile_max_chunk 4k; |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
101 } |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
102 |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 location /t8.html { |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 proxy_pass http://127.0.0.1:8081/t.html; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 proxy_cache_valid 1s; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 } |
1138
d6acd17ca4e3
Tests: added proxy_cache_background_update + if test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1137
diff
changeset
|
108 |
d6acd17ca4e3
Tests: added proxy_cache_background_update + if test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1137
diff
changeset
|
109 if ($arg_if) { |
d6acd17ca4e3
Tests: added proxy_cache_background_update + if test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1137
diff
changeset
|
110 # nothing |
d6acd17ca4e3
Tests: added proxy_cache_background_update + if test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1137
diff
changeset
|
111 } |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 } |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 } |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 server { |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 listen 127.0.0.1:8081; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 server_name localhost; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 add_header Cache-Control $http_x_cache_control; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 |
1178
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
120 if ($arg_lim) { |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
121 set $limit_rate 1k; |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
122 } |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
123 |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 if ($arg_e) { |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 return 500; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 } |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 location / { } |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 location /t6.html { |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 limit_req zone=one burst=2; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 } |
1178
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
133 |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
134 location /t9.html { |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
135 add_header Cache-Control "max-age=1, stale-while-revalidate=10"; |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
136 } |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 } |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 } |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 EOF |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 $t->write_file('t.html', 'SEE-THIS'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 $t->write_file('tt.html', 'SEE-THIS'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 $t->write_file('t2.html', 'SEE-THIS'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 $t->write_file('t3.html', 'SEE-THIS'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 $t->write_file('t6.html', 'SEE-THIS'); |
1178
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
147 $t->write_file('t7.html', 'SEE-THIS' x 1024); |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
148 $t->write_file('t9.html', 'SEE-THIS' x 1024); |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
149 $t->write_file('ssi.html', 'xxx <!--#include virtual="/t9.html" --> xxx'); |
1256
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
150 $t->write_file('escape.html', 'SEE-THIS'); |
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
151 $t->write_file('escape html', 'SEE-THIS'); |
1414
f5b18471e17a
Tests: proxy cache background update with regex captures.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1412
diff
changeset
|
152 $t->write_file('regexp.html', 'SEE-THIS'); |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 |
1587
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
154 $t->run()->plan(36); |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 ############################################################################### |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
158 like(get('/t.html', 'max-age=1, stale-if-error=5'), qr/MISS/, 'stale-if-error'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 like(http_get('/t.html?e=1'), qr/HIT/, 's-i-e - cached'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
160 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
161 like(get('/t2.html', 'max-age=1, stale-while-revalidate=10'), qr/MISS/, |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
162 'stale-while-revalidate'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 like(http_get('/t2.html'), qr/HIT/, 's-w-r - cached'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 |
1230
a3d23d16712d
Tests: adjusted cache validity time in proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1210
diff
changeset
|
165 get('/tt.html', 'max-age=1, stale-if-error=3'); |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 get('/t3.html', 'max-age=1, stale-while-revalidate=2'); |
1230
a3d23d16712d
Tests: adjusted cache validity time in proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1210
diff
changeset
|
167 get('/t4.html', 'max-age=1, stale-while-revalidate=3'); |
a3d23d16712d
Tests: adjusted cache validity time in proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1210
diff
changeset
|
168 get('/t5.html', 'max-age=1, stale-while-revalidate=3'); |
1210
3ca5b0081bc6
Tests: proxy_cache_use_stale.t adjusted.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1186
diff
changeset
|
169 get('/t6.html', 'max-age=1, stale-while-revalidate=4'); |
1178
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
170 get('/t7.html', 'max-age=1, stale-while-revalidate=10'); |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
171 http_get('/ssi.html'); |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 get('/updating/t.html', 'max-age=1'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 get('/updating/t2.html', 'max-age=1, stale-while-revalidate=2'); |
1587
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
174 get('/updating/tt.html', 'max-age=1, stale-if-error=5'); |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 get('/t8.html', 'stale-while-revalidate=10'); |
1256
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
176 get('/escape.htm%6C', 'max-age=1, stale-while-revalidate=10'); |
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
177 get('/escape html', 'max-age=1, stale-while-revalidate=10'); |
1414
f5b18471e17a
Tests: proxy cache background update with regex captures.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1412
diff
changeset
|
178 get('/regexp.html', 'max-age=1, stale-while-revalidate=10'); |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
179 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
180 sleep 2; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
181 |
1587
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
182 TODO: { |
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
183 local $TODO = 'not yet' unless $t->has_version('1.19.3'); |
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
184 |
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
185 # stale 5xx response is ignored since 1.19.3, |
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
186 # "proxy_cache_use_stale updating;" allows to get it still |
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
187 |
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
188 like(http_get('/t.html?e=1'), qr/ 500 /, 's-i-e - stale 5xx ignore'); |
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
189 like(http_get('/tt.html?e=1'), qr/ 500 /, 's-i-e - stale 5xx ignore 2'); |
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
190 |
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
191 } |
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
192 |
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
193 like(http_get('/updating/tt.html'), qr/STALE/, 's-i-e - stale 5xx updating'); |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
194 like(http_get('/t.html'), qr/REVALIDATED/, 's-i-e - revalidated'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
195 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
196 like(http_get('/t2.html?e=1'), qr/STALE/, 's-w-r - revalidate error'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
197 like(http_get('/t2.html'), qr/STALE/, 's-w-r - stale while revalidate'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
198 like(http_get('/t2.html'), qr/HIT/, 's-w-r - revalidated'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
199 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
200 like(get('/t4.html', 'max-age=1, stale-while-revalidate=2'), qr/STALE/, |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
201 's-w-r - unconditional revalidate'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
202 like(http_get('/t4.html'), qr/HIT/, 's-w-r - unconditional revalidated'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
203 |
1587
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
204 TODO: { |
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
205 local $TODO = 'not yet' unless $t->has_version('1.19.3'); |
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
206 |
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
207 like(http_get('/t5.html?e=1'), qr/ 500 /, |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
208 's-w-r - foreground revalidate error'); |
1587
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
209 |
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
210 } |
17b227c271a2
Tests: 4xx and 5xx codes with stale-while-revalidate.
Roman Arutyunyan <arut@nginx.com>
parents:
1535
diff
changeset
|
211 |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
212 like(http_get('/t5.html'), qr/REVALIDATED/, 's-w-r - foreground revalidated'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
213 |
1414
f5b18471e17a
Tests: proxy cache background update with regex captures.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1412
diff
changeset
|
214 # proxy_pass to regular expression with named and positional captures |
f5b18471e17a
Tests: proxy cache background update with regex captures.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1412
diff
changeset
|
215 |
f5b18471e17a
Tests: proxy cache background update with regex captures.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1412
diff
changeset
|
216 like(http_get('/regexp.html'), qr/STALE/, 's-w-r - regexp background update'); |
f5b18471e17a
Tests: proxy cache background update with regex captures.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1412
diff
changeset
|
217 like(http_get('/regexp.html'), qr/HIT/, 's-w-r - regexp revalidated'); |
f5b18471e17a
Tests: proxy cache background update with regex captures.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1412
diff
changeset
|
218 |
1186
0352ed25af20
Tests: converted UTF-8 character to ASCII, no functional changes.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1179
diff
changeset
|
219 # UPDATING while s-w-r |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
220 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
221 $t->write_file('t6.html', 'SEE-THAT'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
222 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
223 my $s = get('/t6.html', 'max-age=1, stale-while-revalidate=2', start => 1); |
1137
129b9e4ca3b3
Tests: reduced race in proxy_cache_use_stale tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1134
diff
changeset
|
224 select undef, undef, undef, 0.2; |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
225 like(http_get('/t6.html'), qr/UPDATING.*SEE-THIS/s, 's-w-r - updating'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
226 like(http_end($s), qr/STALE.*SEE-THIS/s, 's-w-r - updating stale'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
227 like(http_get('/t6.html'), qr/HIT.*SEE-THAT/s, 's-w-r - updating revalidated'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
228 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
229 # stale-while-revalidate with proxy_cache_use_stale updating |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
230 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
231 like(http_get('/updating/t.html'), qr/STALE/, |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
232 's-w-r - use_stale updating stale'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
233 like(http_get('/updating/t.html'), qr/HIT/, |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
234 's-w-r - use_stale updating revalidated'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
235 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
236 # stale-while-revalidate with proxy_cache_valid |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
237 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
238 like(http_get('/t8.html'), qr/STALE/, 's-w-r - proxy_cache_valid revalidate'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
239 like(http_get('/t8.html'), qr/HIT/, 's-w-r - proxy_cache_valid revalidated'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
240 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
241 sleep 2; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
242 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
243 like(http_get('/t2.html?e=1'), qr/STALE/, 's-w-r - stale after revalidate'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
244 like(http_get('/t3.html?e=1'), qr/ 500 /, 's-w-r - ceased'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
245 like(http_get('/tt.html?e=1'), qr/ 500 /, 's-i-e - ceased'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
246 like(http_get('/updating/t2.html'), qr/STALE/, |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
247 's-w-r - overriden with use_stale updating'); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
248 |
1178
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
249 # stale response not blocked by background update. |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
250 # before 1.13.1, if stale response was not sent in one pass, its remaining |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
251 # part was blocked and not sent until background update has been finished |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
252 |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
253 $t->write_file('t7.html', 'SEE-THAT' x 1024); |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
254 |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
255 my $r = read_all(get('/t7.html?lim=1', 'max-age=1', start => 1)); |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
256 like($r, qr/STALE.*^(SEE-THIS){1024}$/ms, 's-w-r - stale response not blocked'); |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
257 |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
258 $t->write_file('t9.html', 'SEE-THAT' x 1024); |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
259 $t->write_file('ssi.html', 'xxx <!--#include virtual="/t9.html?lim=1" --> xxx'); |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
260 |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
261 $r = read_all(http_get('/ssi.html', start => 1)); |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
262 like($r, qr/^xxx (SEE-THIS){1024} xxx$/ms, 's-w-r - not blocked in subrequest'); |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
263 |
1179
660147bfe68c
Tests: TODO proxy_cache_use_stale.t alert seen with "aio_write".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1178
diff
changeset
|
264 # "aio_write" is used to produce "open socket ... left in connection" alerts. |
660147bfe68c
Tests: TODO proxy_cache_use_stale.t alert seen with "aio_write".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1178
diff
changeset
|
265 |
660147bfe68c
Tests: TODO proxy_cache_use_stale.t alert seen with "aio_write".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1178
diff
changeset
|
266 $t->todo_alerts() if $t->read_file('nginx.conf') =~ /aio_write on/ |
660147bfe68c
Tests: TODO proxy_cache_use_stale.t alert seen with "aio_write".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1178
diff
changeset
|
267 and $t->read_file('nginx.conf') =~ /aio threads/ and $^O eq 'freebsd'; |
660147bfe68c
Tests: TODO proxy_cache_use_stale.t alert seen with "aio_write".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1178
diff
changeset
|
268 |
1138
d6acd17ca4e3
Tests: added proxy_cache_background_update + if test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1137
diff
changeset
|
269 # due to the missing content_handler inheritance in a cloned subrequest, |
d6acd17ca4e3
Tests: added proxy_cache_background_update + if test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1137
diff
changeset
|
270 # this used to access a static file in the update request |
d6acd17ca4e3
Tests: added proxy_cache_background_update + if test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1137
diff
changeset
|
271 |
d6acd17ca4e3
Tests: added proxy_cache_background_update + if test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1137
diff
changeset
|
272 like(http_get('/t2.html?if=1'), qr/STALE/, 'background update in if'); |
d6acd17ca4e3
Tests: added proxy_cache_background_update + if test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1137
diff
changeset
|
273 like(http_get('/t2.html?if=1'), qr/HIT/, 'background update in if - updated'); |
d6acd17ca4e3
Tests: added proxy_cache_background_update + if test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1137
diff
changeset
|
274 |
1256
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
275 # ticket #1430, uri escaping in cloned subrequests |
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
276 |
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
277 $t->write_file('escape.html', 'SEE-THAT'); |
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
278 $t->write_file('escape html', 'SEE-THAT'); |
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
279 |
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
280 get('/escape.htm%6C', 'max-age=1'); |
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
281 get('/escape html', 'max-age=1'); |
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
282 |
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
283 like(http_get('/escape.htm%6C'), qr/HIT/, 'escaped after escaped'); |
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
284 like(http_get('/escape.html'), qr/MISS/, 'unescaped after escaped'); |
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
285 like(http_get('/escape html'), qr/HIT/, 'space after escaped space'); |
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
286 like(http_get('/escape%20html'), qr/HIT/, 'escaped space after escaped space'); |
fc43a3555095
Tests: added uri escaping tests to proxy_cache_use_stale.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
287 |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
288 ############################################################################### |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
289 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
290 sub get { |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
291 my ($url, $extra, %extra) = @_; |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
292 return http(<<EOF, %extra); |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
293 GET $url HTTP/1.1 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
294 Host: localhost |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
295 Connection: close |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
296 X-Cache-Control: $extra |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
297 |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
298 EOF |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
299 } |
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
300 |
1178
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
301 # background update is known to postpone closing connection with client |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
302 |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
303 sub read_all { |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
304 my ($s) = @_; |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
305 my $r = ''; |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
306 while (IO::Select->new($s)->can_read(1)) { |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
307 $s->sysread(my $buf, 8192) or last; |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
308 log_in($buf); |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
309 $r .= $buf; |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
310 } |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
311 return $r; |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
312 } |
4039b6b3a75a
Tests: added tests for background subrequests for cache updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1138
diff
changeset
|
313 |
1134
d77c331affff
Tests: proxy_cache_use_stale tests with Cache-Control in response.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
314 ############################################################################### |