microcache_proxy_auth.conf (2287B)
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 proxy_cache microcache; 8 ## The cache key. 9 proxy_cache_key $cache_uid@$host$request_uri; 10 11 ## For 200 and 301 make the cache valid for 15 seconds. 12 proxy_cache_valid 200 301 15s; 13 ## For 302 make it valid for 1 minute. 14 proxy_cache_valid 302 1m; 15 ## For 404 make it valid 1 second. 16 proxy_cache_valid 404 1s; 17 ## If there are any upstream errors or the item has expired use 18 ## whatever it is available. 19 proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504; 20 ## The Cache-Control and Expires headers should be delivered untouched 21 ## from the upstream to the client. 22 proxy_ignore_headers Cache-Control Expires; 23 proxy_pass_header Set-Cookie; 24 proxy_pass_header Cookie; 25 ## Bypass the cache. 26 proxy_cache_bypass $no_auth_cache; 27 proxy_no_cache $no_auth_cache; 28 ## Add a cache miss/hit status header. 29 add_header X-Micro-Cache $upstream_cache_status; 30 ## To avoid any interaction with the cache control headers we expire 31 ## everything on this location immediately. 32 expires epoch; 33 ## Enable clickjacking protection in modern browsers. Available in 34 ## IE8 also. See 35 ## https://developer.mozilla.org/en/The_X-FRAME-OPTIONS_response_header 36 ## This may conflicts with pseudo streaming (at least with Nginx version 1.0.12). 37 ## Uncomment the line below if you're not using media streaming. 38 ## For sites *not* using frames uncomment the line below. 39 #add_header X-Frame-Options DENY; 40 ## For sites *using* frames uncomment the line below. 41 #add_header X-Frame-Options SAMEORIGIN; 42 43 ## Block MIME type sniffing on IE. 44 add_header X-Content-Options nosniff; 45 46 ## If you're using a Nginx version greater than 1.1.11 then uncomment 47 ## the line below. See: 48 ## http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_lock. 49 ## Cache locking mechanism for protecting the backendof too many 50 ## simultaneous requests. 51 #proxy_cache_lock on; 52 ## The default timeout, i.e., the time to way before forwarding the 53 ## second request upstream if no reply as arrived in the meantime is 5s. 54 # proxy_cache_lock_timeout 8000; # in miliseconds.