Files
LEMPer/etc/nginx/fastcgi_cache
2019-08-17 17:18:46 +07:00

46 lines
1.3 KiB
Plaintext

## Include this file if you want to use fastcgi_cache across many sites
# Designed to be included in /etc/nginx/nginx.conf http {} block
fastcgi_cache_path /var/cache/nginx/fastcgi_cache levels=1:2 keys_zone=FASTCGICACHE:100m max_size=1g inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header updating http_500 http_503;
fastcgi_cache_revalidate on;
fastcgi_cache_background_update on;
fastcgi_cache_lock on;
# Ignore header
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
# Designed to be used with Nginx Cache Controller WP plugin
#fastcgi_pass_header "X-Accel-Redirect";
#fastcgi_pass_header "X-Accel-Expires";
# Header status
add_header X-Cache-Status $upstream_cache_status;
# FastCGI Log Format
log_format cache '$remote_addr - $upstream_cache_status [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
# Map Mobile
map $http_user_agent $is_mobile {
default 0;
~*android|ip(hone|ad|od)|windows\s+(?:ce|phone) 1;
~*symbian|sony|samsung|lg|blackberry 1;
~*mobile|mini 1;
}
# Map Cache
# Skip caching on post
map $request_method $skip_cache {
default 0;
POST 1;
}
# Skip PHP Session cookie
map $http_cookie $skip_cache {
default 0;
~SESS 1;
}