From: William A. Rowe Jr Date: Wed, 22 Sep 2010 17:54:39 +0000 (+0000) Subject: Revert breakage in 2.2.4 introduced in r450055, by offering a CacheStoreExpired X-Git-Tag: 2.3.9~458 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9baaf4e80094db6b793b8b0b155c4231dac5d720;p=thirdparty%2Fapache%2Fhttpd.git Revert breakage in 2.2.4 introduced in r450055, by offering a CacheStoreExpired 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 --- diff --git a/docs/manual/mod/mod_cache.xml b/docs/manual/mod/mod_cache.xml index ff30909a2e0..92d552e3fa3 100644 --- a/docs/manual/mod/mod_cache.xml +++ b/docs/manual/mod/mod_cache.xml @@ -584,6 +584,30 @@ LastModified date. + +CacheStoreExpired +Attempt to cache responses that the server reports as expired +CacheStoreExpired On|Off +CacheStoreExpired Off +server configvirtual host + + + +

Since httpd 2.2.4, responses which are already-expired are not stored + stored in the cache. The CacheStoreExpired + directive allows this behavior to be overridden. + CacheStoreExpired 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.

+ + + CacheStoreExpired On + +
+
+ CacheStorePrivate Attempt to cache responses that the server has marked as private diff --git a/modules/cache/mod_cache.c b/modules/cache/mod_cache.c index db1fb2d621b..d1188261cf9 100644 --- a/modules/cache/mod_cache.c +++ b/modules/cache/mod_cache.c @@ -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"), diff --git a/modules/cache/mod_cache.h b/modules/cache/mod_cache.h index c17574adaf3..c77ddc0b107 100644 --- a/modules/cache/mod_cache.h +++ b/modules/cache/mod_cache.h @@ -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;