Mercurial > hg > nginx
comparison src/http/ngx_http_upstream.c @ 5911:88d55e5934f7
Cache: add support for Cache-Control's s-maxage response directive.
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
author | Piotr Sikora <piotr@cloudflare.com> |
---|---|
date | Tue, 18 Nov 2014 17:07:14 -0800 |
parents | 2f7e557eab5b |
children | 8dfee01ff0bd |
comparison
equal
deleted
inserted
replaced
5910:29fa5023bd6f | 5911:88d55e5934f7 |
---|---|
3932 | 3932 |
3933 *ph = h; | 3933 *ph = h; |
3934 | 3934 |
3935 #if (NGX_HTTP_CACHE) | 3935 #if (NGX_HTTP_CACHE) |
3936 { | 3936 { |
3937 u_char *p, *last; | 3937 u_char *p, *start, *last; |
3938 ngx_int_t n; | 3938 ngx_int_t n; |
3939 | 3939 |
3940 if (u->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL) { | 3940 if (u->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL) { |
3941 return NGX_OK; | 3941 return NGX_OK; |
3942 } | 3942 } |
3947 | 3947 |
3948 if (r->cache->valid_sec != 0 && u->headers_in.x_accel_expires != NULL) { | 3948 if (r->cache->valid_sec != 0 && u->headers_in.x_accel_expires != NULL) { |
3949 return NGX_OK; | 3949 return NGX_OK; |
3950 } | 3950 } |
3951 | 3951 |
3952 p = h->value.data; | 3952 start = h->value.data; |
3953 last = p + h->value.len; | 3953 last = start + h->value.len; |
3954 | 3954 |
3955 if (ngx_strlcasestrn(p, last, (u_char *) "no-cache", 8 - 1) != NULL | 3955 if (ngx_strlcasestrn(start, last, (u_char *) "no-cache", 8 - 1) != NULL |
3956 || ngx_strlcasestrn(p, last, (u_char *) "no-store", 8 - 1) != NULL | 3956 || ngx_strlcasestrn(start, last, (u_char *) "no-store", 8 - 1) != NULL |
3957 || ngx_strlcasestrn(p, last, (u_char *) "private", 7 - 1) != NULL) | 3957 || ngx_strlcasestrn(start, last, (u_char *) "private", 7 - 1) != NULL) |
3958 { | 3958 { |
3959 u->cacheable = 0; | 3959 u->cacheable = 0; |
3960 return NGX_OK; | 3960 return NGX_OK; |
3961 } | 3961 } |
3962 | 3962 |
3963 p = ngx_strlcasestrn(p, last, (u_char *) "max-age=", 8 - 1); | 3963 p = ngx_strlcasestrn(start, last, (u_char *) "s-maxage=", 9 - 1); |
3964 offset = 9; | |
3965 | |
3966 if (p == NULL) { | |
3967 p = ngx_strlcasestrn(start, last, (u_char *) "max-age=", 8 - 1); | |
3968 offset = 8; | |
3969 } | |
3964 | 3970 |
3965 if (p == NULL) { | 3971 if (p == NULL) { |
3966 return NGX_OK; | 3972 return NGX_OK; |
3967 } | 3973 } |
3968 | 3974 |
3969 n = 0; | 3975 n = 0; |
3970 | 3976 |
3971 for (p += 8; p < last; p++) { | 3977 for (p += offset; p < last; p++) { |
3972 if (*p == ',' || *p == ';' || *p == ' ') { | 3978 if (*p == ',' || *p == ';' || *p == ' ') { |
3973 break; | 3979 break; |
3974 } | 3980 } |
3975 | 3981 |
3976 if (*p >= '0' && *p <= '9') { | 3982 if (*p >= '0' && *p <= '9') { |