You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Ian Holsman <li...@holsman.net> on 2004/09/07 06:48:05 UTC
mod_cache 2 questions
ok.. so I've started playing with mod-cache again, and I noticed the
following:
- there is no way to cache something with query-args which doesn't
return a expires tag.
proposal: add a CacheIgnoreNoExpires directive so that we can cache them
- Even if we add a optional function to ignore the query-args, we still
check the args to see if the thing is cacheable. I'm not sure what to
do about this.. maybe move some more functionality into the key-gen
code... I don't know.
any objections to adding yet another config option to mod-cache?
Re: mod_cache 2 questions
Posted by "Roy T. Fielding" <fi...@gbiv.com>.
> Just a thought... why does this restriction exist in the first place?
Because, a long time ago, queries contained mostly user-defined
strings that were not likely to result in a later hit, so it wasn't
worth the effort. Now, some web applications use a bogus query
string in order to override caching because of this default behavior.
It would be fine with me to change the default, but that may result
in very inefficient caches. It is better to default to no-cache unless
it is specifically configured or indicated (cache-control) as cacheable.
....Roy
Re: mod_cache 2 questions
Posted by Bill Stoddard <bi...@wstoddard.com>.
Justin Erenkrantz wrote:
> --On Tuesday, September 7, 2004 2:48 PM +1000 Ian Holsman
> <li...@holsman.net> wrote:
>
>> ok.. so I've started playing with mod-cache again, and I noticed the
>> following:
>>
>> - there is no way to cache something with query-args which doesn't return
>> a expires tag.
>>
>> proposal: add a CacheIgnoreNoExpires directive so that we can cache them
>>
>> - Even if we add a optional function to ignore the query-args, we still
>> check the args to see if the thing is cacheable. I'm not sure what to
>> do about this.. maybe move some more functionality into the key-gen
>> code... I don't know.
>>
>> any objections to adding yet another config option to mod-cache?
>
>
> Not really, but I'd like to see a patch posted to this list first before
> committing it. There's a couple ways I could see implementing this, but
> not sure which way you are intending to do this. -- justin
>
Just a thought... why does this restriction exist in the first place? If it is to cover an uncommon occurance,
perhaps we relax the restriction by default and enable the restriction with a CacheNoExpiresStrict (or
similar) config option? Another alternative might be to apply a default expires policy and add an Expires
header to the reply and then run the reply through mod_cache. Just thinking out loud...
Bill
Re: mod_cache 2 questions
Posted by Ian Holsman <ia...@holsman.net>.
Justin Erenkrantz wrote:
> --On Tuesday, September 7, 2004 2:48 PM +1000 Ian Holsman
> <li...@holsman.net> wrote:
>
>
> Not really, but I'd like to see a patch posted to this list first before
> committing it. There's a couple ways I could see implementing this, but
> not sure which way you are intending to do this. -- justin
>
here is the patch I initially did, but I like Bill's idea about adding a
default expiry as well... which could be done in a different way.
ianh:/src/httpd-2.0/modules/experimental ianh$ cvs diff -u
Index: mod_cache.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_cache.c,v
retrieving revision 1.64.2.14
diff -u -u -r1.64.2.14 mod_cache.c
--- mod_cache.c 26 Aug 2004 16:59:44 -0000 1.64.2.14
+++ mod_cache.c 8 Sep 2004 06:13:12 -0000
@@ -445,7 +445,7 @@
/* if a broken Expires header is present, don't cache it */
reason = apr_pstrcat(p, "Broken expires header: ", exps, NULL);
}
- else if (r->args && exps == NULL) {
+ else if (r->args && exps == NULL && (conf->no_expires == 0)) {
/* if query string present but no expiration time, don't cache it
* (RFC 2616/13.9)
*/
@@ -747,6 +747,9 @@
ps->complete_set = 0;
ps->no_last_mod_ignore_set = 0;
ps->no_last_mod_ignore = 0;
+
+ ps->no_expires_set = 0;
+ ps->no_expires = 0;
ps->ignorecachecontrol = 0;
ps->ignorecachecontrol_set = 0 ;
return ps;
@@ -781,6 +784,12 @@
(overrides->no_last_mod_ignore_set == 0)
? base->no_last_mod_ignore
: overrides->no_last_mod_ignore;
+
+ ps->no_expires=
+ (overrides->no_expires_set == 0)
+ ? base->no_expires
+ : overrides->no_expires;
+
ps->ignorecachecontrol =
(overrides->ignorecachecontrol_set == 0)
? base->ignorecachecontrol
@@ -800,7 +809,19 @@
return NULL;
}
+static const char *set_cache_ignore_no_expires(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->no_expires = flag;
+ conf->no_expires_set = 1;
+ return NULL;
+}
static const char *set_cache_ignore_cachecontrol(cmd_parms *parms,
void *dummy, int flag)
{
@@ -942,6 +963,10 @@
AP_INIT_FLAG("CacheIgnoreNoLastMod",
set_cache_ignore_no_last_mod, NULL,
RSRC_CONF,
"Ignore Responses where there is no Last Modified
Header"),
+ AP_INIT_FLAG("CacheIgnoreNoExpires", set_cache_ignore_no_expires,
NULL,
+ RSRC_CONF,
+ "Ignore Check on which forces expires to be present"),
+
AP_INIT_FLAG("CacheIgnoreCacheControl",
set_cache_ignore_cachecontrol,
NULL,
RSRC_CONF,
Index: mod_cache.h
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_cache.h,v
retrieving revision 1.36.2.8
diff -u -u -r1.36.2.8 mod_cache.h
--- mod_cache.h 26 Aug 2004 18:35:13 -0000 1.36.2.8
+++ mod_cache.h 8 Sep 2004 06:13:12 -0000
@@ -130,6 +130,10 @@
/** ignore the last-modified header when deciding to cache this
request */
int no_last_mod_ignore_set;
int no_last_mod_ignore;
+
+ /** disable check of expires header */
+ int no_expires_set;
+ int no_expires;
/** ignore client's requests for uncached responses */
int ignorecachecontrol;
int ignorecachecontrol_set;
Re: mod_cache 2 questions
Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
--On Tuesday, September 7, 2004 2:48 PM +1000 Ian Holsman
<li...@holsman.net> wrote:
> ok.. so I've started playing with mod-cache again, and I noticed the
> following:
>
> - there is no way to cache something with query-args which doesn't return
> a expires tag.
>
> proposal: add a CacheIgnoreNoExpires directive so that we can cache them
>
> - Even if we add a optional function to ignore the query-args, we still
> check the args to see if the thing is cacheable. I'm not sure what to
> do about this.. maybe move some more functionality into the key-gen
> code... I don't know.
>
> any objections to adding yet another config option to mod-cache?
Not really, but I'd like to see a patch posted to this list first before
committing it. There's a couple ways I could see implementing this, but
not sure which way you are intending to do this. -- justin