Created
April 16, 2015 20:26
-
-
Save levnovikov/5610f24e269b105f1f5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location / { | |
try_files $uri @proxy; | |
} | |
location @proxy { | |
proxy_pass http://localhost:8000; | |
proxy_redirect off; | |
#must be set! | |
proxy_ignore_headers X-Accel-Expires Expires Cache-Control; | |
set $no_cache ""; | |
#cache only GET|HEAD | |
if ($request_method !~ ^(GET|HEAD)$) { | |
set $no_cache "1"; | |
} | |
if ($no_cache = "1") { | |
add_header Set-Cookie "_mcnc=1; Max-Age=2; Path=/"; | |
add_header X-Microcachable "0"; | |
} | |
if ($http_cookie ~* "_mcnc") { | |
set $no_cache "1"; | |
} | |
proxy_cache microcache; | |
proxy_no_cache $no_cache; | |
proxy_cache_bypass $no_cache; | |
proxy_cache_key $scheme$host$request_method$request_uri; | |
proxy_cache_valid 200 301 302 3s; | |
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504 http_403 http_404 updating; | |
default_type application/json; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment