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

Chris Carter cdcarter at gmail.com
Sun Dec 10 21:09:17 EST 2006


Hi,
Do you store logged_in in a cookie, or in the session?

On 12/10/06, Shinji Kuwayama <shinji at kuwayama.com> wrote:
>
> 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
>
>
>
>
> _______________________________________________
> Mongrel-users mailing list
> Mongrel-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mongrel-users
>
>


-- 
Chris Carter
concentrationstudios.com
brynmawrcs.com


More information about the Mongrel-users mailing list