Shinji Kuwayama
2006-Dec-11 01:34 UTC
[Mongrel] Does mongrel look at the Rails page cache?
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
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
Shinji Kuwayama
2006-Dec-11 02:38 UTC
[Mongrel] Does mongrel look at the Rails page cache?
Oh, it''s definitely in a cookie. That part seems to be working ok; if "logged_in=yes" cookie exists: (1) go-ahead with proxy request proxy:balancer://mongrel_cluster/ [OK] if not: (1) go-ahead with /var/sites/production/public/index.html [OK] ... which seems right. It''s just that the static file shows up in the browser either way. On Dec 10, 2006, at 8:09 PM, Chris Carter wrote:> 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 > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-usersShinji Kuwayama shinji at kuwayama.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20061210/a2eeadee/attachment-0001.html