include /www/server/nginx/conf/wpproxycache.conf;
#============ WordPress 动态页面不缓存 ===========
set $skip_cache 0;
#post访问不缓存
if ($request_method = POST) {
set $skip_cache 1;
}
#动态查询不缓存
if ($query_string != "") {
set $skip_cache 1;
}
#后台等特定页面不缓存(其他需求请自行添加即可)
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
set $skip_cache 1;
}
#对登录用户、评论过的用户不展示缓存
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}
proxy_no_cache $skip_cache;
#缓存清理配置(可选模块,请安装 nginx helper 插件)
location ~ /purge(/.*) {
allow 127.0.0.1;
allow $YOUR_VPS_IP;
deny all;
proxy_cache_purge cache_one "$host$uri$is_args$args";
}
#============ WordPress 动态页面不缓存 ===========
proxy_ignore_headers Set-Cookie Cache-Control expires; proxy_cache cache_one; proxy_cache_key $host$uri$is_args$args; proxy_cache_valid 200 304 301 302 120m;
