httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anthony J. Biacco" <>
Subject RE: rewrite before caching?
Date Fri, 20 Mar 2009 16:34:37 GMT
Yeah, it would create twice the number of requests to my server. One for
the initial hit and the other for the redirect. If it was a small % of
my hits, I wouldn't care, but this url is about 90% of my web server

Manager, IT Operations
Format Dynamics, Inc.

-----Original Message-----
From: Houser, Rick [] 
Sent: Friday, March 20, 2009 6:51 AM
Subject: RE: rewrite before caching?

Is there a reason you can't just change your rewrite rule to a [R=301]?


Rick Houser
Auto-Owners Insurance
Systems Support

-----Original Message-----
From: Anthony J. Biacco [] 
Sent: Thursday, March 19, 2009 4:53 PM
Subject: RE: rewrite before caching?

Sorry, no, these are in httpd.conf, I don't use any htaccess files.
The situation is, this particular path was going to tomcat through
mod_jk, and initially the dev guys didn't want the data cached in
tomcat, so they introduced the killCache parameter in referencing
content (before my existence in the company).
But then down the road I decided to start caching this data in apache to
relieve unnecessary load on our tomcats (and with the understanding that
at this time in our application's timeline, the data now could be
And while we changed the referencing urls that we had access to, to
remove the killCache parameter, there are some references out of our
control (currently) that still use it. So I want to now take those
requests and implement the caching for them also until the point where
we can get the people controlling the remaining references to change
On the current (changed) url, I'm now setting the appropriate
cache-control and expire headers.
My current idea is using rewrite I can set an environmental variable on
the existence of killCache in the query string and then use that to set
a no-cache header and unset the expires header, that will make sure the
killCache request doesn't get cached to disk. The internally rewritten
url won't get served from cache then also, but I figure I can always do
an internal proxy with the [P] flag, and then the proxied rewritten
request will pull from cache.
I'll still get 2 requests in the log due to the proxy request, but I can
use a SetEnvIf Remote_Host to check for the local server ip (denoting
the proxied request) and not log the entry based on that.
It's ugly, I hate that I have to do it, and the proxy request will still
consume more resources than I'd like, but may just be more beneficial
than sending the killCache requests through to tomcat.
Opinions would be appreciated on my suggestion, privately if you want,
as I don't want to get too OT here.

Manager, IT Operations
Format Dynamics, Inc.

-----Original Message-----
From: Ray Morris []
Sent: Thursday, March 19, 2009 2:22 PM
Subject: Re: rewrite before caching?

   If you're doing your rewrite in .htaccess, it _MAY_ help to move that
rewrite to httpd.conf.
In many cases rewrite rules in httpd.conf get processed at an earlier
stage than those in .htaccess.  This is becase Apace can't read the
.htacces file until after it resolves the URL into a filename, so it
knows which directories to look for .htaccess files in.  That occurs
quite late in the process, during the fixup hook.

   Other than that, I can only suggest that there are several http
headers designed for the purpose of controlling caching so that just the
right things are cached for just the right amount of time, and only
under the right conditions.  Using that carefully designed and well
established system may yield better results than the "big hammer"
approach of sticking bogus junk into the URL, then trying to remove it
later for certain kinds of caching.  You've added that to try to prevent
caching, yet clearly the content SHOULD be cached in some cases, as is
clear because you are actually wanting to cache it.  Rather than
inventing your own caching system, look into setting the appropriate
headers so that it's cached when appropriate and for the appropriate
amount of time.
Ray B. Morris

Strongbox - The next generation in site security:

Throttlebox - Intelligent Bandwidth Control

Strongbox / Throttlebox affiliate program:

On 03/19/2009 02:36:23 PM, Anthony J. Biacco wrote:
> I posted this on the users list, but didn't get any help, so I'm 
> hoping the dev people here can either help or at least explain if what

> I'm seeing below is how it's meant to work..
> I have a uri with cachebusting in it that looks like this:
> /path?killCache=x&parameter1=y%parameter2=z
> where x is a unix timestamp used to make sure the url isn't cached by 
> the browser.
> Now though I want to use apache disk caching on this url. Obviously 
> with the killCache parameters always changing though, this is futile. 
> And I can't ignore the query string with CacheIgnoreQueryString 
> because
> parameter1 and parameter2 are important to the output to the end- 
> user, so the cache would be inconsistent if I had caching ignore the 
> query string.
> So I decided to rewrite the url to remove the killCache parameter, and

> while this rule itself works fine (I'm rewriting to a path not a full 
> url), it seems the cache check is done before the rewrite.
> My rule is:
> RewriteCond %{QUERY_STRING}
> ^killCache=(.+)\&parameter1=(.+)\&parameter2=(.+)
> RewriteRule ^/path /path?parameter1=%2&parameter2=%3 [L]
> And in the log I see:
>  [Wed Mar 18 12:02:47 2009] [debug] mod_cache.c(131): Adding 
> CACHE_SAVE filter for /path [Wed Mar 18 12:02:47 2009] [debug] 
> mod_cache.c(138): Adding CACHE_REMOVE_URL filter for /path [Wed Mar 18

> 12:02:47 2009] [debug] mod_headers.c(740): headers:
> ap_headers_output_filter()
> mod_cache.c(639): cache: Caching url:
> /path?killCache=x&parameter1=y&parameter2=z
> [Wed Mar 18 12:02:47 2009] [debug] mod_cache.c(645): cache: Removing 
> [Wed Mar 18 12:02:47 2009] [debug] mod_disk_cache.c(962): disk_cache:
> Stored headers for URL
> http://myhost/path?killCache=x&parameter1=y&parameter2=z
> [Wed Mar 18 12:02:47 2009] [debug] mod_disk_cache.c(1051): 
> disk_cache:
> Body for URL http://myhost/path?killCache=x&parameter1=y&parameter2=z
> cached.
> And I get a different cache file stored for every value of the 
> parameter killCache.
> Anybody know a way to get the rewriterule processed before the cache 
> mechanism? I can rewrite to a full url and the new request will then 
> pull from cache, but that induces an extra request and an extra log 
> entry, which I'd like to avoid if at all possible.
> Thanx,
> -Tony
> ---------------------------
> Manager, IT Operations
> Format Dynamics, Inc.
> 303-573-1800x27

View raw message