[Mongrel] Does mongrel look at the Rails page cache?

Shinji Kuwayama shinji at kuwayama.com
Sun Dec 10 20:34:28 EST 2006


Hi all. I'm trying to skip the Rails page cache if the user is logged  
in:

---
  # Rewrite index to check for static
RewriteCond %{HTTP_COOKIE} !^.*logged_in=yes.*$
RewriteRule ^/$ /index.html [QSA]

# Rewrite to check for Rails cached page
RewriteCond %{HTTP_COOKIE} !^.*logged_in=yes.*$
RewriteRule ^([^.]+)$ $1.html [QSA]

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

It does seem to work -- here's sample rewrite debug for "/":

---
(2) init rewrite engine with requested uri /
(3) applying pattern '^.*$' to uri '/'
(4) RewriteCond: input='/var/sites/production/public/system/ 
maintenance.html' pattern='-f' => not-matched
(3) applying pattern '^/$' to uri '/'
(4) RewriteCond: input='[other cookies]; logged_in=yes;' pattern='! 
^.*logged_in=yes.*$' => not-matched
(3) applying pattern '^([^.]+)$' to uri '/'
(4) RewriteCond: input='[other cookies]; logged_in=yes;' pattern='! 
^.*logged_in=yes.*$' => not-matched
(3) applying pattern '^/(.*)$' to uri '/'
(4) RewriteCond: input='/var/sites/production/public//' pattern='!-f'  
=> matched
(2) rewrite '/' -> 'balancer://mongrel_cluster/'
(2) forcing proxy-throughput with balancer://mongrel_cluster/
(1) go-ahead with proxy request proxy:balancer://mongrel_cluster/ [OK]
---

(As opposed to "go-ahead with /var/sites/production/public/ 
index.html", if the user's not logged in.)

Problem: The static file is still being served to the browser. Can  
anyone tell me what I'm missing here?


Shinji Kuwayama
shinji at kuwayama.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20061210/61cbe612/attachment.html 


More information about the Mongrel-users mailing list