[Mongrel] Moving page_cache_directory

Ian C. Blenke ian at blenke.com
Tue Oct 31 10:20:28 EST 2006

Russell Norris wrote:

> Howdy. I'm working on a RoR CMS and need cached pages to all be in 
> public/cache rather than public [in order to set svn:ignore on all the 
> files properly]. I can get page_cache_directory set correctly and the 
> pages are cached in the right place but Mongrel isn't serving them 
> because it's only looking for them in public. During development I 
> know I can set -r public/cache but doing that means that the images 
> and stylesheets don't get picked up. I'm sure there's a way to tell 
> Mongrel to look in both places or at least to serve assets from public 
> and cached pages from public/cache. Isn't there?

You can always do this with apache.

  # Redirect any requests for cached content that exist to the cached url.
  RewriteCond %{DOCUMENT_ROOT}/cache/%{REQUEST_FILENAME} -f
  RewriteRule ^/(.*)$ /cache/$1 [PT]

  # Redirect all non-static requests to cluster
  RewriteCond %{DOCUMENT_ROOT}/cache/%{REQUEST_FILENAME} !-f
  RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]

Or something like that (NOTE: I haven't tested the above, but it "feels" 

- Ian C. Blenke <ian at blenke.com> http://ian.blenke.com/

More information about the Mongrel-users mailing list