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 2013/05/07 18:16:16 UTC

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

Author: minfrin
Date: Tue May  7 16:16:16 2013
New Revision: 1479966

URL: http://svn.apache.org/r1479966
Log:
mod_cache: Ensure that we don't attempt to replace a cached response
with an older response as per RFC2616 13.12.

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=1479966&r1=1479965&r2=1479966&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Tue May  7 16:16:16 2013
@@ -1,6 +1,10 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) mod_cache: Ensure that we don't attempt to replace a cached response
+     with an older response as per RFC2616 13.12. [Graham Leggett, Co-Advisor
+     <coad measurement-factory.com>]
+
   *) core, mod_cache: Ensure RFC2616 compliance in ap_meets_conditions()
      with weak validation combined with If-Range and Range headers. Break
      out explicit conditional header checks to be useable elsewhere in the

Modified: httpd/httpd/trunk/modules/cache/mod_cache.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_cache.c?rev=1479966&r1=1479965&r2=1479966&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/cache/mod_cache.c (original)
+++ httpd/httpd/trunk/modules/cache/mod_cache.c Tue May  7 16:16:16 2013
@@ -1089,6 +1089,25 @@ static apr_status_t cache_save_filter(ap
         /* or we've been asked not to cache it above */
         reason = "r->no_cache present";
     }
+    else if (cache->stale_handle
+            && APR_DATE_BAD
+                    != (date = apr_date_parse_http(
+                            apr_table_get(r->headers_out, "Date")))
+            && date < cache->stale_handle->cache_obj->info.date) {
+
+        /**
+         * 13.12 Cache Replacement:
+         *
+         * Note: a new response that has an older Date header value than
+         * existing cached responses is not cacheable.
+         */
+        reason = "updated entity is older than cached entity";
+
+        /* while this response is not cacheable, the previous response still is */
+        ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00770)
+                "cache: Removing CACHE_REMOVE_URL filter.");
+        ap_remove_output_filter(cache->remove_url_filter);
+    }
     else if (r->status == HTTP_NOT_MODIFIED && cache->stale_handle) {
         apr_table_t *left = cache->stale_handle->resp_hdrs;
         apr_table_t *right = r->headers_out;