microcache_fcgi.conf (1579B)
1 # -*- mode: nginx; mode: flyspell-prog; ispell-local-dictionary: "american" -*- 2 3 ### Implementation of the microcache concept as presented here: 4 ### http://fennb.com/microcaching-speed-your-app-up-250x-with-no-n 5 6 ## The cache zone referenced. 7 fastcgi_cache microcache; 8 ## The cache key. 9 fastcgi_cache_key $scheme$request_method$host$request_uri; 10 11 ## For 200 and 301 make the cache valid for 1s seconds. 12 fastcgi_cache_valid 200 301 1s; 13 ## For 302 make it valid for 1 minute. 14 fastcgi_cache_valid 302 1m; 15 ## For 404 make it valid 1 second. 16 fastcgi_cache_valid 404 1s; 17 ## If there are any upstream errors or the item has expired use 18 ## whatever it is available. 19 fastcgi_cache_use_stale error timeout invalid_header updating http_500; 20 ## The Cache-Control and Expires headers should be delivered untouched 21 ## from the upstream to the client. 22 fastcgi_ignore_headers Cache-Control Expires; 23 ## Bypass the cache. 24 fastcgi_cache_bypass $no_cache; 25 fastcgi_no_cache $no_cache; 26 27 ## To avoid any interaction with the cache control headers we expire 28 ## everything on this location immediately. 29 expires epoch; 30 31 ## If you're using a Nginx version greater than 1.1.11 then uncomment 32 ## the line below. See: 33 ## http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_cache_lock 34 ## Cache locking mechanism for protecting the backend of too many 35 ## simultaneous requests. 36 #fastcgi_cache_lock on; 37 ## The default timeout, i.e., the time to way before forwarding the 38 ## second request upstream if no reply as arrived in the meantime is 5s. 39 #fastcgi_cache_lock_timeout 8000; # in miliseconds.