Skip to content

Commit 7847927

Browse files
committed
Store also 307, 308 by default
1 parent 68444aa commit 7847927

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

README.markdown

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Synopsis
9696
set $key $uri$args;
9797
srcache_fetch GET /memc $key;
9898
srcache_store PUT /memc $key;
99-
srcache_store_statuses 200 301 302;
99+
srcache_store_statuses 200 301 302 307 308;
100100
101101
# proxy_pass/fastcgi_pass/drizzle_pass/echo/etc...
102102
# or even static files on the disk
@@ -276,7 +276,7 @@ Here is a working example using the lua-resty-redis module:
276276
srcache_store_skip $skip_cache;
277277
278278
srcache_response_cache_control off;
279-
srcache_store_statuses 200 201 301 302 404 503;
279+
srcache_store_statuses 200 201 301 302 307 308 404 503;
280280
281281
set_escape_uri $escaped_key $key;
282282
@@ -300,7 +300,7 @@ Here is a working example using the lua-resty-redis module:
300300
301301
fastcgi_pass upstream-name;
302302
}
303-
303+
304304
location /redis-fetch {
305305
internal;
306306
@@ -639,21 +639,21 @@ srcache_store_statuses
639639
----------------------
640640
**syntax:** *srcache_store_statuses <status1> <status2> ..*
641641

642-
**default:** *srcache_store_statuses 200 301 302*
642+
**default:** *srcache_store_statuses 200 301 302 307 308*
643643

644644
**context:** *http, server, location, location if*
645645

646646
**phase:** *output-header-filter*
647647

648648
This directive controls what responses to store to the cache according to their status code.
649649

650-
By default, only `200`, `301`, and `302` responses will be stored to cache and any other responses will skip [srcache_store](#srcache_store).
650+
By default, only `200`, `301`, `302`, `307` and `308` responses will be stored to cache and any other responses will skip [srcache_store](#srcache_store).
651651

652652
You can specify arbitrary positive numbers for the response status code that you'd like to cache, even including error code like `404` and `503`. For example:
653653

654654
```nginx
655655
656-
srcache_store_statuses 200 201 301 302 404 503;
656+
srcache_store_statuses 200 201 301 302 307 308 404 503;
657657
```
658658

659659
At least one argument should be given to this directive.

src/ngx_http_srcache_store.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,14 @@ ngx_http_srcache_header_filter(ngx_http_request_t *r)
213213

214214
if (r->headers_out.status != NGX_HTTP_OK
215215
&& r->headers_out.status != NGX_HTTP_MOVED_TEMPORARILY
216-
&& r->headers_out.status != NGX_HTTP_MOVED_PERMANENTLY)
216+
&& r->headers_out.status != NGX_HTTP_MOVED_PERMANENTLY
217+
&& r->headers_out.status != NGX_HTTP_TEMPORARY_REDIRECT
218+
&& r->headers_out.status != NGX_HTTP_PERMANENT_REDIRECT)
217219
{
218220
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
219221
"srcache_store bypassed because of unmatched status "
220-
"code %i (only 200, 301, or 302 are accepted by "
221-
"default)", r->headers_out.status);
222+
"code %i (only 200, 301, 302, 307, or 308 are accepted "
223+
"by default)", r->headers_out.status);
222224

223225
return ngx_http_srcache_next_header_filter(r);
224226
}

0 commit comments

Comments
 (0)