Hi,

I have some problems with the behavior of mod_cache.

I'm running httpd-2.2.4 under FreeBSD 6.2, and I'm trying to get
mod_cache (both mem_cache, and disk_cache) to work to optimize
performance. Unfortunately our users often requests static files with
query strings, there are explanations for this but this is outside the
scope of the problem, we are not able to control this behavior.

I.e. requests look like this:
http://host/file.html?ref=0

Ideally we would like to be able to tell mod_cache to cache this as
being static even though there is a query string. I would be very happy
to see this feature in the next version. We can tell mod_cache to cache
it anyway, and we do, by using mod_expire and adding an expire header.
Now the problem is that since each query string is unique (ref=0,1,2...
for example), they get cached as different requests...

Ok, so lets rewrite the url. I use "RewriteCond %{QUERY_STRING} !^$" and
"RewriteRule .* %{REQUEST_URI}?" which seems to do the trick. Relevant
parts of httpd.conf below.

Now the incorrect behavior seems to start.

First request: (http://host/file.html?ref=1)
[Wed Jan 17 16:36:00 2007] [debug] mod_cache.c(129): Adding CACHE_SAVE
filter for /file.html
[Wed Jan 17 16:36:00 2007] [debug] mod_cache.c(136): Adding
CACHE_REMOVE_URL filter for /file.html
[Wed Jan 17 16:36:00 2007] [debug] mod_cache.c(609): cache: Caching url:
/file.html?ref=1
[Wed Jan 17 16:36:00 2007] [debug] mod_cache.c(615): cache: Removing
CACHE_REMOVE_URL filter.
[Wed Jan 17 16:36:00 2007] [debug] mod_cache.c(658): cache: Added date
header
[Wed Jan 17 16:36:00 2007] [info] mem_cache: Cached url:
http://localhost:80/file.html?

1. line 3 mod_cache.c(609) doesn't use the rewritten request.
2. line 6 mod_cache use a rewritten request, though without '?' would be
preferable.

Second similar request is exactly the same. For some reason I always
have to request something 2 times before the cache functionality sets
in. This seems to be a bug as well.

Third similar request: (http://host/file.html?ref=1)
[Wed Jan 17 16:51:24 2007] [debug] mod_cache.c(129): Adding CACHE_SAVE
filter for /file.html.swf
[Wed Jan 17 16:51:24 2007] [debug] mod_cache.c(136): Adding
CACHE_REMOVE_URL filter for /file.html.swf
[Wed Jan 17 16:51:24 2007] [debug] mod_cache.c(609): cache: Caching url:
/file.html?ref=1
[Wed Jan 17 16:51:24 2007] [debug] mod_cache.c(615): cache: Removing
CACHE_REMOVE_URL filter.
[Wed Jan 17 16:51:24 2007] [debug] mod_cache.c(658): cache: Added date
header
[Wed Jan 17 16:51:24 2007] [debug] mod_cache.c(803): (13)Permission
denied: cache: store_headers failed

1. I believe this request doesn't match "file.html?" against
"file.html?ref=1" and therefore doesn't find the content in the cache,
and tries to recache the same url, and fails.

Fourth request with unique query string" (http://host/file.html?ref=2)
[Wed Jan 17 16:53:53 2007] [debug] mod_cache.c(129): Adding CACHE_SAVE
filter for /file.html.swf
[Wed Jan 17 16:53:53 2007] [debug] mod_cache.c(136): Adding
CACHE_REMOVE_URL filter for /file.html.swf
[Wed Jan 17 16:53:53 2007] [debug] mod_cache.c(609): cache: Caching url:
/file.html?ref=2
[Wed Jan 17 16:53:53 2007] [debug] mod_cache.c(615): cache: Removing
CACHE_REMOVE_URL filter.
[Wed Jan 17 16:53:53 2007] [debug] mod_cache.c(658): cache: Added date
header
[Wed Jan 17 16:53:53 2007] [debug] mod_cache.c(803): (13)Permission
denied: cache: store_headers failed

1. Again match against the unrewritten request, tries to cache it as the
rewritten request.

I.e. the problems are, or seems to be:

- The cache delivery doesn't kick in until 2 valid requests have been made.
- When removing the query string, mod_cache still caches "file.html?"
which differs from "file.html".
- mod_cache seems to match a request with cached entries using the
unrewritten request, but stores the entry with the rewritten request.

Kind regards,
Fredrik Widlund

[httpd.conf]
...
RewriteEngine On
RewriteLog "/log/httpd-rewrite.log"
RewriteLogLevel 10
RewriteCond %{QUERY_STRING} !^$
RewriteRule .* %{REQUEST_URI}?
                                                                                
                        

ExpiresActive on
ExpiresDefault "access plus 1 week"
                                                                                
                                                  

<IfModule mod_mem_cache.c>
   CacheEnable mem /
   MCacheSize 524288
   MCacheMaxObjectCount 1009
   MCacheMinObjectSize 1
   MCacheMaxObjectSize 1048575
</IfModule>
                                                                                
                                                  

<IfModule mod_disk_cache.c>
   CacheRoot /cache
   CacheEnable disk /
   CacheDirLevels 5
   CacheDirLength 4
   CacheMinFileSize 1
   CacheMaxFileSize 104857600
</IfModule>
                                                                                
                                                  

                                                                                
                                                  

                  

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: [EMAIL PROTECTED]
   "   from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to