comparison src/http/ngx_http_upstream.c @ 3597:0d8b8c84bab7 stable-0.7

merge r3518, r3527: cache related fixes: *) do not cache response if it has "no-store" or "private" in "Cache-Control" header *) proxy_no_cache and fastcgi_no_cache
author Igor Sysoev <igor@sysoev.ru>
date Mon, 07 Jun 2010 12:23:23 +0000
parents d963fa32847e
children 8152369f7037
comparison
equal deleted inserted replaced
3596:555de5bdb800 3597:0d8b8c84bab7
583 ngx_http_upstream_cache(ngx_http_request_t *r, ngx_http_upstream_t *u) 583 ngx_http_upstream_cache(ngx_http_request_t *r, ngx_http_upstream_t *u)
584 { 584 {
585 ngx_int_t rc; 585 ngx_int_t rc;
586 ngx_http_cache_t *c; 586 ngx_http_cache_t *c;
587 587
588 if (u->conf->no_cache) {
589 rc = ngx_http_cache(r, u->conf->no_cache);
590 if (rc != NGX_OK) {
591 return rc;
592 }
593 }
594
588 if (!(r->method & u->conf->cache_methods)) { 595 if (!(r->method & u->conf->cache_methods)) {
589 return NGX_DECLINED; 596 return NGX_DECLINED;
590 } 597 }
591 598
592 if (r->method & NGX_HTTP_HEAD) { 599 if (r->method & NGX_HTTP_HEAD) {
3000 3007
3001 if (r->cache->valid_sec != 0) { 3008 if (r->cache->valid_sec != 0) {
3002 return NGX_OK; 3009 return NGX_OK;
3003 } 3010 }
3004 3011
3005 last = h->value.data + h->value.len; 3012 p = h->value.data;
3006 3013 last = p + h->value.len;
3007 if (ngx_strlcasestrn(h->value.data, last, (u_char *) "no-cache", 8 - 1) 3014
3008 != NULL) 3015 if (ngx_strlcasestrn(p, last, (u_char *) "no-cache", 8 - 1) != NULL
3016 || ngx_strlcasestrn(p, last, (u_char *) "no-store", 8 - 1) != NULL
3017 || ngx_strlcasestrn(p, last, (u_char *) "private", 7 - 1) != NULL)
3009 { 3018 {
3010 u->cacheable = 0; 3019 u->cacheable = 0;
3011 return NGX_OK; 3020 return NGX_OK;
3012 } 3021 }
3013 3022
3014 p = ngx_strlcasestrn(h->value.data, last, (u_char *) "max-age=", 8 - 1); 3023 p = ngx_strlcasestrn(p, last, (u_char *) "max-age=", 8 - 1);
3015 3024
3016 if (p == NULL) { 3025 if (p == NULL) {
3017 return NGX_OK; 3026 return NGX_OK;
3018 } 3027 }
3019 3028