mirror of
https://github.com/joglomedia/LEMPer.git
synced 2026-04-13 08:28:21 +00:00
55 lines
1.5 KiB
Plaintext
55 lines
1.5 KiB
Plaintext
## Nginx Proxy cache configs.
|
|
# Designed to be included in any server {} directive block.
|
|
|
|
# Skip^1 caching variable init
|
|
set $skip_cache 0;
|
|
|
|
# Bypass^2 caching variable init
|
|
set $purge_cache 0;
|
|
|
|
# Bypass^2 cache on no-cache (et al.) browser request
|
|
if ($http_cache_control ~ "max-age=0")
|
|
{ set $purge_cache 1; }
|
|
|
|
if ($http_cache_control ~ "no-cache")
|
|
{ set $purge_cache 1; }
|
|
|
|
# Bypass^2 cache with custom header set on request
|
|
if ($http_x_cache_purge ~* "true")
|
|
{ set $purge_cache 1; }
|
|
|
|
# Cache pool
|
|
proxy_cache PROXYCACHE;
|
|
|
|
# Bypass^2 cache when $purge_cache is set to 1.
|
|
# Bypass means that content is served fresh and the cache is updated
|
|
proxy_cache_bypass $purge_cache;
|
|
|
|
# Skip^1 caching when $skip_cache is set to 1
|
|
# Do not cache when browsing frontend as logged user
|
|
proxy_no_cache $skip_cache;
|
|
|
|
# Define the cache resource identifier. Be careful to add $skip_cache
|
|
proxy_cache_key "$scheme$request_method$host$request_uri$skip_cache";
|
|
|
|
## Ref: http://wiki.nginx.org/FullExample2
|
|
proxy_redirect off;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_connect_timeout 30;
|
|
proxy_send_timeout 30;
|
|
proxy_read_timeout 30;
|
|
proxy_buffer_size 4k;
|
|
proxy_buffers 4 32k;
|
|
proxy_busy_buffers_size 64k;
|
|
proxy_temp_file_write_size 64k;
|
|
proxy_cache_valid 200 302 1h;
|
|
proxy_cache_valid 301 1d;
|
|
proxy_cache_valid 404 1m;
|
|
proxy_cache_valid any 2m;
|
|
|
|
charset koi8-r;
|
|
|
|
#proxy_pass http://127.0.0.1:8080;
|