Skip to content

Instantly share code, notes, and snippets.

@beardcoder beardcoder/my-page.vhost
Last active Feb 20, 2018

Embed
What would you like to do?
Neos FastCGI Cache with nginx
server {
set $fastcgi_skipcache 0;
if ($query_string) {
set $fastcgi_skipcache 1;
}
if ($http_x_custom_header) {
set $fastcgi_skipcache 0;
}
if ($uri ~ "/neos") {
set $fastcgi_skipcache 1;
}
if ($http_cookie ~ "Neos_Session") {
set $fastcgi_skipcache 1;
}
location @php {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
{FASTCGIPASS}
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param FLOW_CONTEXT Production;
fastcgi_param FLOW_REWRITEURLS 1;
add_header X-Cache $upstream_cache_status;
fastcgi_cache fastcgicache;
fastcgi_cache_bypass $fastcgi_skipcache;
fastcgi_no_cache $fastcgi_skipcache;
include /etc/nginx/fastcgi_params;
}
}
http {
fastcgi_cache_path /var/cache/nginxfastcgi levels=1:2 keys_zone=fastcgicache:10m inactive=10m max_size=64m;
fastcgi_cache_key $scheme$request_method$host$request_uri;
# note: can also use HTTP headers to form the cache key, e.g.
#fastcgi_cache_key $scheme$request_method$host$request_uri$http_x_custom_header;
fastcgi_cache_lock on;
fastcgi_cache_use_stale error timeout invalid_header updating http_500;
fastcgi_cache_valid 1m;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
fastcgi_cache_revalidate on;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.