You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Davi Arnaut <da...@haxent.com.br> on 2006/06/14 21:53:50 UTC
[PATCH] Don't cache expired objects
Hi,
Don't cache requests with a expires date in the past; otherwise the cache code
will _always_ try to cache the URL, leading to numerous rename() errors - since
the URL is already cached.
--
Davi Arnaut
Index: modules/cache/mod_cache.c
===================================================================
--- modules/cache/mod_cache.c (revision 414393)
+++ modules/cache/mod_cache.c (working copy)
@@ -426,6 +426,9 @@
/* if a broken Expires header is present, don't cache it */
reason = apr_pstrcat(p, "Broken expires header: ", exps, NULL);
}
+ else if (exps != NULL && exp != APR_DATE_BAD && exp < apr_time_now()) {
+ reason = "Expires header already expired, not cacheable";
+ }
else if (r->args && exps == NULL) {
/* if query string present but no expiration time, don't cache it
* (RFC 2616/13.9)
Re: [PATCH] Don't cache expired objects
Posted by Davi Arnaut <da...@haxent.com.br>.
On Thu, 22 Jun 2006 06:35:05 -0700
Paul Querna <ch...@force-elite.com> wrote:
> Davi Arnaut wrote:
> > Don't cache requests with a expires date in the past; otherwise the cache code
> > will _always_ try to cache the URL, leading to numerous rename() errors - since
> > the URL is already cached.
> ...
> > Index: modules/cache/mod_cache.c
> > ===================================================================
> > --- modules/cache/mod_cache.c (revision 414393)
> > +++ modules/cache/mod_cache.c (working copy)
> > @@ -426,6 +426,9 @@
> > /* if a broken Expires header is present, don't cache it */
> > reason = apr_pstrcat(p, "Broken expires header: ", exps, NULL);
> > }
> > + else if (exps != NULL && exp != APR_DATE_BAD && exp < apr_time_now()) {
> > + reason = "Expires header already expired, not cacheable";
> > + }
> > else if (r->args && exps == NULL) {
> > /* if query string present but no expiration time, don't cache it
> > * (RFC 2616/13.9)
>
>
> Instead of calling apr_time_now(), shouldn't it re-use r->request_time
> here, saving a possibly expensive call?
>
> Otherwise, I think its a good fix.
>
Good catch, thanks!
--
Davi Arnaut
Index: mod_cache.c
===================================================================
--- mod_cache.c (revision 416367)
+++ mod_cache.c (working copy)
@@ -426,6 +426,9 @@
/* if a broken Expires header is present, don't cache it */
reason = apr_pstrcat(p, "Broken expires header: ", exps, NULL);
}
+ else if (exps != NULL && exp != APR_DATE_BAD && exp < r->request_time) {
+ reason = "Expires header already expired, not cacheable";
+ }
else if (r->args && exps == NULL) {
/* if query string present but no expiration time, don't cache it
* (RFC 2616/13.9)
Re: [PATCH] Don't cache expired objects
Posted by Paul Querna <ch...@force-elite.com>.
Davi Arnaut wrote:
> Don't cache requests with a expires date in the past; otherwise the cache code
> will _always_ try to cache the URL, leading to numerous rename() errors - since
> the URL is already cached.
...
> Index: modules/cache/mod_cache.c
> ===================================================================
> --- modules/cache/mod_cache.c (revision 414393)
> +++ modules/cache/mod_cache.c (working copy)
> @@ -426,6 +426,9 @@
> /* if a broken Expires header is present, don't cache it */
> reason = apr_pstrcat(p, "Broken expires header: ", exps, NULL);
> }
> + else if (exps != NULL && exp != APR_DATE_BAD && exp < apr_time_now()) {
> + reason = "Expires header already expired, not cacheable";
> + }
> else if (r->args && exps == NULL) {
> /* if query string present but no expiration time, don't cache it
> * (RFC 2616/13.9)
Instead of calling apr_time_now(), shouldn't it re-use r->request_time
here, saving a possibly expensive call?
Otherwise, I think its a good fix.
-Paul