map_cache.conf (1260B)
1 # -*- mode: nginx; mode: flyspell-prog; ispell-current-dictionary: american -*- 2 3 ### Testing if we should be serving content from cache or not. This is 4 ### needed for any Drupal setup that uses an external cache. 5 6 ## Let Ajax calls go through. 7 map $uri $no_cache_ajax { 8 default 0; 9 /system/ajax 1; 10 } 11 12 ## Testing for the session cookie being present. If there is then no 13 ## caching is to be done. Note that this is for someone using either 14 ## Drupal 7 pressflow or stock Drupal 6 core with no_anon 15 ## (http://drupal.org/project/no_anon). 16 map $http_cookie $no_cache_cookie { 17 default 0; 18 ~SESS 1; # PHP session cookie 19 } 20 21 ## Combine both results to get the cache bypassing mapping. 22 map $no_cache_ajax$no_cache_cookie $no_cache { 23 default 1; 24 00 0; 25 } 26 27 ## If you're using stock Drupal 6 without no_anon, i.e., there's a 28 ## session cookie being served even to anonymous users, then uncomment 29 ## the three lines below and comment the above map directive 30 # map $http_cookie $no_cache { 31 # default 0; 32 # ~DRUPAL_UID 1; # DRUPAL_UID cookie set by Boost 33 # } 34 35 ## Set a cache_uid variable for authenticated users. 36 map $http_cookie $cache_uid { 37 default nil; # hommage to Lisp :) 38 ~SESS[[:alnum:]]+=(?<session_id>[[:graph:]]+) $session_id; 39 }