httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John den Haan <john.h...@chello.nl>
Subject [users@httpd] mod_cache not serving URLs ending in slash?
Date Thu, 24 Dec 2009 11:31:25 GMT
Hello,

For my web server, I want to set up a disk-based cache. To allow this, I 
have configured as follows:

<IfModule mod_disk_cache.c>
CacheRoot /var/cache/httpd
CacheDirLength 2
</IfModule>
# Enable cache
<IfModule mod_cache.c>
CacheEnable disk /
CacheDisable /textpattern
CacheDisable /images
CacheDefaultExpire 86400
CacheIgnoreCacheControl On
CacheIgnoreHeaders Set-Cookie
</IfModule>

Using mod_rewrite, I have arranged my site's URL structure like 
http://www.domain.com/section/page/. In my debug logs, I see mod_cache 
is not serving the /page/. It does cache every time, but doesn't serve 
from the cache upon subsequent requests. Here are some logs describing 
the problem:

[Thu Dec 24 01:34:54 2009] [debug] mod_cache.c(131): Adding CACHE_SAVE 
filter for /
[Thu Dec 24 01:34:54 2009] [debug] mod_cache.c(138): Adding 
CACHE_REMOVE_URL filter for /
[Thu Dec 24 01:34:54 2009] [debug] mod_cache.c(131): Adding CACHE_SAVE 
filter for /index.php/
[Thu Dec 24 01:34:54 2009] [debug] mod_cache.c(138): Adding 
CACHE_REMOVE_URL filter for /index.php/
[Thu Dec 24 01:34:54 2009] [debug] mod_headers.c(743): headers: 
ap_headers_output_filter()
[Thu Dec 24 01:34:54 2009] [debug] mod_cache.c(663): cache: Caching url: 
/index.php/
[Thu Dec 24 01:34:54 2009] [debug] mod_cache.c(669): cache: Removing 
CACHE_REMOVE_URL filter.
[Thu Dec 24 01:34:54 2009] [debug] mod_disk_cache.c(977): disk_cache: 
Stored headers for URL http://www.domain.com:80/index.php/?
[Thu Dec 24 01:34:54 2009] [debug] mod_disk_cache.c(1066): disk_cache: 
Body for URL http://www.domain.com:80/index.php/? cached.

It appears Apache is using the rewritten URL to identify the cache 
entry. i.e. the cache module sees my page not as http://www.domain.com/ 
but as /index.php, per the generic rewrite in my .htaccess file. Since 
all my pages rewrite internally to /index.php, the wrong content is 
bound to be served. To fix this, I have had to change my rewrite to 
/index.php to a rewrite to /index.php/$1. This makes sure all my pages 
have a unique identifier for mod_cache to work with.

However still, the directory index (which is my CMS-generated content) 
is cached, but it is re-cached on every load. You can see this in the 
first few lines of the log entry, where the module doesn't even check 
for the presence of a cached version, but instead immediately proceeds 
to apply a SAVE - filter. I have tried an ugly workaround involving 
adding a constant to the rewrite (i.e. rewriting to /index.php/$1cache), 
but that also fails, because the module apparently applies its SAVE 
filter both to the requested and rewritten URL. Isn't there a clean way 
to solve this problem?

Thanks!

John

---------------------------------------------------------------------
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: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message