Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I just enabled mod_mem_cache on an Apache2/PHP5 server running a custom app, and was horrified at the result. All of a sudden the wrong images were being served, and I noticed one time a request for an HTML page served up a CSS page instead! What could be causing this? Config is as follows:

CacheEnable mem /
MCacheSize 204800
CacheDefaultExpire 3600
CacheIgnoreHeaders Set-Cookie
MCacheMinObjectSize 100
MCacheMaxObjectSize 5242880
MCacheRemovalAlgorithm LRU
share|improve this question
add comment

2 Answers

Internally within mod_cache and mod_*_cache the lookup keys are quite lengthy checksums, of the canonical URI and any Vary: parameters (for negotiated content). It's incredibly unlikely that these lookup keys would collide, so if you are getting incorrect responses for the above configuration it seems like a bug.

I'm one of the authors of the caching modules, and if you could either mail details of the request to me (colm@apache.org) and dev@httpd.apache.org, or file a bug with some details we can use to reproduce - http://httpd.apache.org/bug_report.html - we can get on it.

Or feel free to post them here, and we'll work through the problem.

share|improve this answer
1  
+1 Just for using serverfault as a tech support tool. Nice job apache. –  Kevin Kuphal Jul 22 '09 at 16:00
    
I second Kevin's +1! Thanks for your assistance colmmac, I'll post details a bit later this afternoon. –  Josh Jul 22 '09 at 19:06
add comment
up vote 0 down vote accepted

I found the problem. I was using mod_rewrite to rewtite URLs to files that didn't exist to a PHP script which would dispatch those URLs to the proper module. Because all these virtual URLs were being rewritten to the same URL, mod_cache was getting confused. To resolve this, I changed the following part of my Apache config:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /dispatch.php

To:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) /dispatch.php/$1

And now caching seems to work perfectly!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.