-
-
Save mauricerenck/fe7325926d25e9ed9126 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
## DEFAULT | |
set $no_cache 0; | |
## RULES | |
if ( $request_uri ~ "/wp-" ) { | |
set $no_cache 1; | |
} | |
if ( $http_cookie ~ (wp-postpass|wordpress_logged_in|comment_author)_ ) { | |
set $no_cache 1; | |
} | |
## INIT | |
fastcgi_cache microcache; | |
fastcgi_cache_use_stale updating; | |
fastcgi_hide_header "Set-Cookie"; | |
fastcgi_cache_valid any 30m; | |
fastcgi_no_cache $no_cache; | |
fastcgi_cache_bypass $no_cache; | |
## HEADER | |
add_header X-Cache $upstream_cache_status; |
This file contains hidden or 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
http { | |
## ... ## | |
fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=microcache:5m max_size=5m inactive=1h; | |
fastcgi_cache_key "$request_method|$http_if_modified_since|$http_if_none_match|$host|$request_uri"; | |
## ... ## | |
} |
This file contains hidden or 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
server { | |
## ... ## | |
location ~ \.php$ { | |
## ... ## | |
include /etc/nginx/conf.d/fastcgi_cache; | |
## ... ## | |
} | |
## ... ## | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment