]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_cache: When content is served stale, and there is no means to
authorGraham Leggett <minfrin@apache.org>
Sun, 15 May 2011 18:15:48 +0000 (18:15 +0000)
committerGraham Leggett <minfrin@apache.org>
Sun, 15 May 2011 18:15:48 +0000 (18:15 +0000)
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

CHANGES
modules/cache/mod_cache.c

diff --git a/CHANGES b/CHANGES
index 29cc6cb132c992c475c2d7967b03b5eb5b2cb7f8..0ee5b5781c3c4b30515801fdfa908bc8f2879e6d 100644 (file)
--- 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]
index 5ff8c2c621da986eefc5cb912a0d37b13811d5db..fae4546ad08a91ac6b56ab54265be45464ac73d4 100644 (file)
@@ -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,