Caching front page depending on cookie

If a user is not logged in, the front page is exactly the same. I asked
a question a while back and it worked for my scenario then:

http://www.ruby-forum.com/topic/210602

That was when I had nginx on the front and apache on the back. I was
using a proxy. Now I’m using fastcgi.

How can I say something like “If a cookie is not set, serve the cached
page. Otherwise, pass to fast cgi”.

I’m using a more recent development version of nginx.

On Fri, Sep 17, 2010 at 03:30:11PM +0200, Thomas Delonge wrote:

I’m using a more recent development version of nginx.

location = / {
fastcgi_pass …
fastcgi_cache …
fastcgi_cache_bypass $cookie_NAME;
fastcgi_no_cache $cookie_NAME; # to not save response in
cache
}


Igor S.
http://sysoev.ru/en/

Igor S. wrote:

On Fri, Sep 17, 2010 at 03:30:11PM +0200, Thomas Delonge wrote:

I’m using a more recent development version of nginx.

location = / {
fastcgi_pass …
fastcgi_cache …
fastcgi_cache_bypass $cookie_NAME;
fastcgi_no_cache $cookie_NAME; # to not save response in
cache
}


Igor S.
http://sysoev.ru/en/

So where is it caching it? And how can I be sure I’ve set it up right to
see if it’s serving the cached page? Thanks.

On Fri, Sep 17, 2010 at 04:11:59PM +0200, Thomas Delonge wrote:

 fastcgi_no_cache      $cookie_NAME;  # to not save response in 

cache
}


Igor S.
http://sysoev.ru/en/

So where is it caching it?

http {
factcgi_cache_path /path/to/cache keys_zone=CACHE:10m;

server {
    location = / {
       fastcgi_cache  CACHE;
       ...

And how can I be sure I’ve set it up right to
see if it’s serving the cached page? Thanks.

If you request with cookie “NAME” fastcgi_cache_bypass forbids to look
up
cache. You may log $cookie_NAME and $upstream_cache_status variables
to how requests are served.


Igor S.
http://sysoev.ru/en/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs