-
-
Save serguk89/b22a2bd44907a961efcda65798723999 to your computer and use it in GitHub Desktop.
Nginx fast cgi cache for OctoberCMS
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
#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