Skip to content

Instantly share code, notes, and snippets.

@mauricerenck
Forked from sergejmueller/fastcgi_cache
Created August 18, 2014 12:12
Show Gist options
  • Save mauricerenck/fe7325926d25e9ed9126 to your computer and use it in GitHub Desktop.
Save mauricerenck/fe7325926d25e9ed9126 to your computer and use it in GitHub Desktop.
## 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;
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";
## ... ##
}
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