You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mi...@apache.org on 2011/05/15 20:15:49 UTC

svn commit: r1103494 - in /httpd/httpd/trunk: CHANGES modules/cache/mod_cache.c

Author: minfrin
Date: Sun May 15 18:15:48 2011
New Revision: 1103494

URL: http://svn.apache.org/viewvc?rev=1103494&view=rev
Log:
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.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/modules/cache/mod_cache.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1103494&r1=1103493&r2=1103494&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Sun May 15 18:15:48 2011
@@ -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]

Modified: httpd/httpd/trunk/modules/cache/mod_cache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_cache.c?rev=1103494&r1=1103493&r2=1103494&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_cache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_cache.c Sun May 15 18:15:48 2011
@@ -967,11 +967,18 @@ static int cache_save_filter(ap_filter_t
         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,