views:

71

answers:

0

I'm setting up a rails app with simple page caching. (First time I've tried using page caching.)

The cached pages are being created. I have my cache folder set to /public/cache. The cached pages are automatically being created according to their URL, which follows the published date (to avoid filename collisions). I don't have any custom code, this just seems to be the default way rails is storing the cached pages. For example:

/public/cache/2009/10/12/filename.html

However, my app seems to hit the controller every time those pages are accessed, at least judging from the logs. (I'm assuming that if the cached pages are served directly by apache, then nothing should appear in my logs when executing that URL.)

My apache conf is set up to serve static htmls, but I think the problem is that it's looking only in the /public/cache folder, and not any subfolders:

Here's my apache rewrite rule:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^cache/(.*) - [C]
RewriteRule ^(.*)$ cache/$1 [QSA]
# If nothing is found, send to rails
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

However, this isn't working. I'm not sure if Apache isn't looking in subfolders under cache, or these lines are wrong, or what. Rails continue serving up the requests of apache doing so from the cached files.