]> granicus.if.org Git - apache/commitdiff
Revert breakage in 2.2.4 introduced in r450055, by offering a CacheStoreExpired
authorWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 22 Sep 2010 17:54:39 +0000 (17:54 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 22 Sep 2010 17:54:39 +0000 (17:54 +0000)
directive to allow the user to override this questionable change.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1000106 13f79535-47bb-0310-9956-ffa450edef68

docs/manual/mod/mod_cache.xml
modules/cache/mod_cache.c
modules/cache/mod_cache.h

index ff30909a2e09b89f03066eb0bde5bd19cd3fedc6..92d552e3fa301eb24b815eb2f56d47988b4e1a47 100644 (file)
@@ -584,6 +584,30 @@ LastModified date.</description>
 </usage>
 </directivesynopsis>
 
+<directivesynopsis>
+<name>CacheStoreExpired</name>
+<description>Attempt to cache responses that the server reports as expired</description>
+<syntax>CacheStoreExpired On|Off</syntax>
+<default>CacheStoreExpired Off</default>
+<contextlist><context>server config</context><context>virtual host</context>
+</contextlist>
+
+<usage>
+    <p>Since httpd 2.2.4, responses which are already-expired are not stored
+       stored in the cache.  The <directive>CacheStoreExpired</directive>
+       directive allows this behavior to be overridden.
+       <directive>CacheStoreExpired</directive> On
+       tells the server to attempt to cache the resource if it is stale.
+       Subsequent requests would trigger an If-Modified-Since request of
+       the origin server, and the response may be fulfilled from cache
+       if the backend resource has not changed.</p>
+
+    <example>
+      CacheStoreExpired On
+    </example>
+</usage>
+</directivesynopsis>
+
 <directivesynopsis>
 <name>CacheStorePrivate</name>
 <description>Attempt to cache responses that the server has marked as private</description>
index db1fb2d621b022b533ea92a5927675e9281b7c8a..d1188261cf9441f8ecef16ad28e870068dd5ed68 100644 (file)
@@ -817,7 +817,8 @@ static int cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in)
         /* if a broken Expires header is present, don't cache it */
         reason = apr_pstrcat(p, "Broken expires header: ", exps, NULL);
     }
-    else if (exp != APR_DATE_BAD && exp < r->request_time)
+    else if (!conf->store_expired && exp != APR_DATE_BAD
+                                  && exp < r->request_time)
     {
         /* if a Expires header is in the past, don't cache it */
         reason = "Expires header already expired, not cacheable";
@@ -1340,6 +1341,8 @@ static void * create_cache_config(apr_pool_t *p, server_rec *s)
     ps->no_last_mod_ignore = 0;
     ps->ignorecachecontrol = 0;
     ps->ignorecachecontrol_set = 0;
+    ps->store_expired = 0;
+    ps->store_expired_set = 0;
     ps->store_private = 0;
     ps->store_private_set = 0;
     ps->store_nostore = 0;
@@ -1397,6 +1400,10 @@ static void * merge_cache_config(apr_pool_t *p, void *basev, void *overridesv)
         (overrides->ignorecachecontrol_set == 0)
         ? base->ignorecachecontrol
         : overrides->ignorecachecontrol;
+    ps->store_expired  =
+        (overrides->store_expired_set == 0)
+        ? base->store_expired
+        : overrides->store_expired;
     ps->store_private  =
         (overrides->store_private_set == 0)
         ? base->store_private
@@ -1478,6 +1485,19 @@ static const char *set_cache_ignore_cachecontrol(cmd_parms *parms,
     return NULL;
 }
 
+static const char *set_cache_store_expired(cmd_parms *parms, void *dummy,
+                                           int flag)
+{
+    cache_server_conf *conf;
+
+    conf =
+        (cache_server_conf *)ap_get_module_config(parms->server->module_config,
+                                                  &cache_module);
+    conf->store_expired = flag;
+    conf->store_expired_set = 1;
+    return NULL;
+}
+
 static const char *set_cache_store_private(cmd_parms *parms, void *dummy,
                                            int flag)
 {
@@ -1812,6 +1832,10 @@ static const command_rec cache_cmds[] =
     AP_INIT_FLAG("CacheIgnoreCacheControl", set_cache_ignore_cachecontrol,
                  NULL, RSRC_CONF,
                  "Ignore requests from the client for uncached content"),
+    AP_INIT_FLAG("CacheStoreExpired", set_cache_store_expired,
+                 NULL, RSRC_CONF,
+                 "Ignore expiration dates when populating cache, resulting in "
+                 "an If-Modified-Since request to the backend on retrieval"),
     AP_INIT_FLAG("CacheStorePrivate", set_cache_store_private,
                  NULL, RSRC_CONF,
                  "Ignore 'Cache-Control: private' and store private content"),
index c17574adaf301feb3fe643ff895c852b5e48c779..c77ddc0b107e0a13387946c4c635d2a04d68ead6 100644 (file)
@@ -141,6 +141,9 @@ typedef struct {
     /** ignore client's requests for uncached responses */
     int ignorecachecontrol;
     int ignorecachecontrol_set;
+    /** ignore expiration date from server */
+    int store_expired;
+    int store_expired_set;
     /** ignore Cache-Control: private header from server */
     int store_private;
     int store_private_set;