0

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

2 Answers 2

3

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 ([email protected]) and [email protected], 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.

2
  • 1
    +1 Just for using serverfault as a tech support tool. Nice job apache. Jul 22, 2009 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, 2009 at 19:06
0

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!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .