summaryrefslogtreecommitdiff
path: root/etc/nginx/apps/drupal/microcache_proxy.conf
blob: 67086848fdfed9b982e5fc462eefa18ae88c9c4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- 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.
proxy_cache microcache;
## The cache key.
proxy_cache_key $host$request_uri;

## For 200 and 301 make the cache valid for 15 seconds.
proxy_cache_valid 200 301 15s;
## For 302 make it valid for 1 minute.
proxy_cache_valid 302 1m;
## For 404 make it valid 1 second.
proxy_cache_valid 404 1s;
## If there are any upstream errors or the item has expired use
## whatever it is available.
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
## The Cache-Control and Expires headers should be delivered untouched
## from the upstream to the client.
proxy_ignore_headers Cache-Control Expires;
## Bypass the cache.
proxy_cache_bypass $no_cache;
proxy_no_cache $no_cache;
## Add a cache miss/hit status header.
add_header X-Micro-Cache $upstream_cache_status;
## To avoid any interaction with the cache control headers we expire
## everything on this location immediately.
expires epoch;

## Enable clickjacking protection in modern browsers. Available in
## IE8 also. See
## https://developer.mozilla.org/en/The_X-FRAME-OPTIONS_response_header
## This may conflicts with pseudo streaming (at least with Nginx version 1.0.12).
## Uncomment the line below if you're not using media streaming.
## For sites *not* using frames uncomment the line below.
#add_header X-Frame-Options DENY;
## For sites *using* frames uncomment the line below.
#add_header X-Frame-Options SAMEORIGIN;

## Block MIME type sniffing on IE.
add_header X-Content-Options nosniff;

## 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_proxy_module.html#proxy_cache_lock.
## Cache locking mechanism for protecting the backendof too many
## simultaneous requests.
#proxy_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.
# proxy_cache_lock_timeout 8000; # in miliseconds.