Multiple caching solutions for anonymous and logged in users withSSI on

Max nginxyz at mail.ru
Tue Mar 6 17:54:01 UTC 2012




06 марта 2012, 14:02 от "Antonio P.P. Almeida" <appa at perusio.net>:
> > Thanks Antonio.
> >
> > On a side note, if I craft a proxy cache key with cookie_sessionid and if
> > the sessionid cookie does not exist, *will nginx take it as an empty
> > value*?
> 
> Sure. Here's an example using map.
> 
> map $http_cookie $cache_id {
> default nil; # hommage to Lisp :)
> ~SESS[[:alnum:]]+=(?<session_id>[[:graph:]]+) $session_id;
> }
> 
> When there's no SESS cookie then $cache_id is nil.
> 
> 
> > Can nginx do a try_files or 'if' on the existence of a cookie? This
> > will
> > help me deliver two caching strategies in the same location directive.
> 
> Sure. Example. At the http level:
> 
> map $http_cookie $cookie_exists {
> default 0;
> ~<regex testing cookie> 1;
> }
> 
> On the "main" cache location:
> 
> error_page 418 @other-cache-location;
> 
> if ($cookie_exists) {
> return 418;
> }
> 
> Something of this kind will work.
> 
> --appa
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx


More information about the nginx mailing list