From: Graham Leggett Date: Sun, 15 May 2011 18:15:48 +0000 (+0000) Subject: mod_cache: When content is served stale, and there is no means to X-Git-Tag: 2.3.13~128 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4133460ec1cbb1eaeabad2e913f6d8dd76df220;p=thirdparty%2Fapache%2Fhttpd.git mod_cache: When content is served stale, and there is no means to revalidate the content using ETag or Last-Modified, and we have mandated no stale-on-error behaviour, stand down and don't cache. Saves a cache write that will never be read. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1103494 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 29cc6cb132c..0ee5b5781c3 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,12 @@ Changes with Apache 2.3.13 + *) mod_cache: When content is served stale, and there is no means to + revalidate the content using ETag or Last-Modified, and we have + mandated no stale-on-error behaviour, stand down and don't cache. + Saves a cache write that will never be read. + [Graham Leggett] + *) mod_reqtimeout: Fix a timed out connection going into the keep-alive state after a timeout when discarding a request body. PR 51103. [Stefan Fritsch] diff --git a/modules/cache/mod_cache.c b/modules/cache/mod_cache.c index 5ff8c2c621d..fae4546ad08 100644 --- a/modules/cache/mod_cache.c +++ b/modules/cache/mod_cache.c @@ -967,11 +967,18 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in) reason = apr_pstrcat(p, "Broken expires header: ", exps, NULL); } else if (!dconf->store_expired && exp != APR_DATE_BAD - && exp < r->request_time) - { + && exp < r->request_time) { /* if a Expires header is in the past, don't cache it */ reason = "Expires header already expired; not cacheable"; } + else if (!dconf->store_expired && (control.must_revalidate + || control.proxy_revalidate) && (!control.s_maxage_value + || (!control.s_maxage && !control.max_age_value)) && lastmod + == NULL && etag == NULL) { + /* if we're already stale, but can never revalidate, don't cache it */ + reason + = "s-maxage or max-age zero and no Last-Modified or Etag; not cacheable"; + } else if (!conf->ignorequerystring && r->parsed_uri.query && exps == NULL && !control.max_age && !control.s_maxage) { /* if a query string is present but no explicit expiration time,