@@ -86,3 +86,221 @@ Content-Length:
86
86
--- response_body
87
87
world
88
88
89
+
90
+
91
+ === TEST 4: flush all
92
+ --- config
93
+ location /flush {
94
+ set $memc_cmd 'flush_all';
95
+ memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
96
+ }
97
+ --- response_headers
98
+ Content-Type: text/plain
99
+ Content-Length: 4
100
+ --- request
101
+ GET /flush
102
+ --- response_body eval: "OK\r\n"
103
+
104
+
105
+
106
+ === TEST 5: basic fetch (cache miss), and not stored due to Cache-Control: private (srcache_store_private off)
107
+ --- config
108
+ location /foo {
109
+ default_type text/css;
110
+ srcache_fetch GET /memc $uri;
111
+ srcache_store PUT /memc $uri;
112
+ srcache_store_private off;
113
+
114
+ content_by_lua '
115
+ ngx.header.cache_control = "private"
116
+ ngx.say("hello")
117
+ ';
118
+ }
119
+
120
+ location /memc {
121
+ internal;
122
+
123
+ set $memc_key $query_string;
124
+ set $memc_exptime 300;
125
+ memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
126
+ }
127
+ --- request
128
+ GET /foo
129
+ --- response_headers
130
+ Content-Type: text/css
131
+ Content-Length:
132
+ --- response_body
133
+ hello
134
+
135
+
136
+
137
+ === TEST 6: basic fetch (cache miss again, not stored in the previous case)
138
+ --- config
139
+ location /foo {
140
+ default_type text/css;
141
+ srcache_fetch GET /memc $uri;
142
+ srcache_store PUT /memc $uri;
143
+
144
+ echo world;
145
+ }
146
+
147
+ location /memc {
148
+ internal;
149
+
150
+ set $memc_key $query_string;
151
+ set $memc_exptime 300;
152
+ memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
153
+ }
154
+ --- request
155
+ GET /foo
156
+ --- response_headers
157
+ Content-Type: text/css
158
+ Content-Length:
159
+ --- response_body
160
+ world
161
+
162
+
163
+
164
+ === TEST 7: flush all
165
+ --- config
166
+ location /flush {
167
+ set $memc_cmd 'flush_all';
168
+ memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
169
+ }
170
+ --- response_headers
171
+ Content-Type: text/plain
172
+ Content-Length: 4
173
+ --- request
174
+ GET /flush
175
+ --- response_body eval: "OK\r\n"
176
+
177
+
178
+
179
+ === TEST 8: basic fetch (cache miss), and stored due to srcache_store_private on
180
+ --- config
181
+ location /foo {
182
+ default_type text/css;
183
+ srcache_fetch GET /memc $uri;
184
+ srcache_store PUT /memc $uri;
185
+ srcache_store_private on;
186
+
187
+ content_by_lua '
188
+ ngx.header.cache_control = "private"
189
+ ngx.say("hello")
190
+ ';
191
+ }
192
+
193
+ location /memc {
194
+ internal;
195
+
196
+ set $memc_key $query_string;
197
+ set $memc_exptime 300;
198
+ memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
199
+ }
200
+ --- request
201
+ GET /foo
202
+ --- response_headers
203
+ Content-Type: text/css
204
+ Content-Length:
205
+ --- response_body
206
+ hello
207
+
208
+
209
+
210
+ === TEST 9: basic fetch (cache miss again, not stored in the previous case)
211
+ --- config
212
+ location /foo {
213
+ default_type text/css;
214
+ srcache_fetch GET /memc $uri;
215
+ srcache_store PUT /memc $uri;
216
+
217
+ echo world;
218
+ }
219
+
220
+ location /memc {
221
+ internal;
222
+
223
+ set $memc_key $query_string;
224
+ set $memc_exptime 300;
225
+ memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
226
+ }
227
+ --- request
228
+ GET /foo
229
+ --- response_headers
230
+ Content-Type: text/css
231
+ Content-Length: 6
232
+ --- response_body
233
+ hello
234
+
235
+
236
+
237
+ === TEST 10: flush all
238
+ --- config
239
+ location /flush {
240
+ set $memc_cmd 'flush_all';
241
+ memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
242
+ }
243
+ --- response_headers
244
+ Content-Type: text/plain
245
+ Content-Length: 4
246
+ --- request
247
+ GET /flush
248
+ --- response_body eval: "OK\r\n"
249
+
250
+
251
+
252
+ === TEST 11: basic fetch (cache miss), and not stored due to Cache-Control: private
253
+ --- config
254
+ location /foo {
255
+ default_type text/css;
256
+ srcache_fetch GET /memc $uri;
257
+ srcache_store PUT /memc $uri;
258
+
259
+ content_by_lua '
260
+ ngx.header.cache_control = { "blah", "blah; Private" }
261
+ ngx.say("hello")
262
+ ';
263
+ }
264
+
265
+ location /memc {
266
+ internal;
267
+
268
+ set $memc_key $query_string;
269
+ set $memc_exptime 300;
270
+ memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
271
+ }
272
+ --- request
273
+ GET /foo
274
+ --- response_headers
275
+ Content-Type: text/css
276
+ Content-Length:
277
+ --- response_body
278
+ hello
279
+
280
+
281
+
282
+ === TEST 12: basic fetch (cache miss again, not stored in the previous case)
283
+ --- config
284
+ location /foo {
285
+ default_type text/css;
286
+ srcache_fetch GET /memc $uri;
287
+ srcache_store PUT /memc $uri;
288
+
289
+ echo world;
290
+ }
291
+
292
+ location /memc {
293
+ internal;
294
+
295
+ set $memc_key $query_string;
296
+ set $memc_exptime 300;
297
+ memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
298
+ }
299
+ --- request
300
+ GET /foo
301
+ --- response_headers
302
+ Content-Type: text/css
303
+ Content-Length:
304
+ --- response_body
305
+ world
306
+
0 commit comments