aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPiotr Sikora <piotr@cloudflare.com>2014-11-18 17:07:14 -0800
committerPiotr Sikora <piotr@cloudflare.com>2014-11-18 17:07:14 -0800
commit3ecac9eaba3b1392523ca36554b4db1405fbf914 (patch)
tree3518e62b765c0a16f3a4b9252c6965dc11700d3d /src
parent1b79cb211d0e7004fa5f001cd035e567f56f4d91 (diff)
downloadnginx-3ecac9eaba3b1392523ca36554b4db1405fbf914.tar.gz
nginx-3ecac9eaba3b1392523ca36554b4db1405fbf914.zip
Cache: add support for Cache-Control's s-maxage response directive.
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
Diffstat (limited to 'src')
-rw-r--r--src/http/ngx_http_upstream.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index d3e82829a..3d267bda9 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -3934,7 +3934,7 @@ ngx_http_upstream_process_cache_control(ngx_http_request_t *r,
#if (NGX_HTTP_CACHE)
{
- u_char *p, *last;
+ u_char *p, *start, *last;
ngx_int_t n;
if (u->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL) {
@@ -3949,18 +3949,24 @@ ngx_http_upstream_process_cache_control(ngx_http_request_t *r,
return NGX_OK;
}
- p = h->value.data;
- last = p + h->value.len;
+ start = h->value.data;
+ last = start + h->value.len;
- if (ngx_strlcasestrn(p, last, (u_char *) "no-cache", 8 - 1) != NULL
- || ngx_strlcasestrn(p, last, (u_char *) "no-store", 8 - 1) != NULL
- || ngx_strlcasestrn(p, last, (u_char *) "private", 7 - 1) != NULL)
+ if (ngx_strlcasestrn(start, last, (u_char *) "no-cache", 8 - 1) != NULL
+ || ngx_strlcasestrn(start, last, (u_char *) "no-store", 8 - 1) != NULL
+ || ngx_strlcasestrn(start, last, (u_char *) "private", 7 - 1) != NULL)
{
u->cacheable = 0;
return NGX_OK;
}
- p = ngx_strlcasestrn(p, last, (u_char *) "max-age=", 8 - 1);
+ p = ngx_strlcasestrn(start, last, (u_char *) "s-maxage=", 9 - 1);
+ offset = 9;
+
+ if (p == NULL) {
+ p = ngx_strlcasestrn(start, last, (u_char *) "max-age=", 8 - 1);
+ offset = 8;
+ }
if (p == NULL) {
return NGX_OK;
@@ -3968,7 +3974,7 @@ ngx_http_upstream_process_cache_control(ngx_http_request_t *r,
n = 0;
- for (p += 8; p < last; p++) {
+ for (p += offset; p < last; p++) {
if (*p == ',' || *p == ';' || *p == ' ') {
break;
}