Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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 ( and, or file a bug with some details we can use to reproduce - - we can get on it.

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

share|improve this answer
+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
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


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

And now caching seems to work perfectly!

share|improve this answer

Your Answer


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.