Skip to content

Instantly share code, notes, and snippets.

@khoatran
Created June 26, 2017 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save khoatran/96b0e3cd383e572a1490d7e19fb32eb7 to your computer and use it in GitHub Desktop.
Save khoatran/96b0e3cd383e572a1490d7e19fb32eb7 to your computer and use it in GitHub Desktop.
Nginx fast cgi cache for OctoberCMS
#Set the path where the cache is stored; Set the zone name, totalsize (400m),and max life time(60m)
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=AICUNGXINH:400m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
#fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
server {
set $skip_cache 0;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $skip_cache 1;
}
if ($query_string != "") {
set $skip_cache 1;
}
#Don't cache uris containing the following segments
if ($request_uri ~* "/backend/|/gio-hang/|index.php|sitemap(_index)?.xml") {
set $skip_cache 1;
}
# Don't use the cache for logged in users
if ($http_cookie ~* "user_auth") {
set $skip_cache 1;
}
if ($http_x_requested_with = XMLHttpRequest) {
set $skip_cache 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment