Caching front page depending on cookie

Igor Sysoev igor at sysoev.ru
Fri Sep 17 18:18:46 MSD 2010


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

> Igor Sysoev 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 Sysoev
> > 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 Sysoev
http://sysoev.ru/en/



More information about the nginx mailing list