# -*- mode: nginx; mode: flyspell-prog; ispell-local-dictionary: "american" -*- ### Implementation of the microcache concept as presented here: ### http://fennb.com/microcaching-speed-your-app-up-250x-with-no-n ## The cache zone referenced. fastcgi_cache microcache; ## The cache key. fastcgi_cache_key $scheme$request_method$host$request_uri; ## For 200 and 301 make the cache valid for 1s seconds. fastcgi_cache_valid 200 301 1s; ## For 302 make it valid for 1 minute. fastcgi_cache_valid 302 1m; ## For 404 make it valid 1 second. fastcgi_cache_valid 404 1s; ## If there are any upstream errors or the item has expired use ## whatever it is available. fastcgi_cache_use_stale error timeout invalid_header updating http_500; ## The Cache-Control and Expires headers should be delivered untouched ## from the upstream to the client. fastcgi_ignore_headers Cache-Control Expires; ## Bypass the cache. fastcgi_cache_bypass $no_cache; fastcgi_no_cache $no_cache; ## To avoid any interaction with the cache control headers we expire ## everything on this location immediately. expires epoch; ## If you're using a Nginx version greater than 1.1.11 then uncomment ## the line below. See: ## http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_cache_lock ## Cache locking mechanism for protecting the backend of too many ## simultaneous requests. #fastcgi_cache_lock on; ## The default timeout, i.e., the time to way before forwarding the ## second request upstream if no reply as arrived in the meantime is 5s. #fastcgi_cache_lock_timeout 8000; # in miliseconds.