wp硬查数据库,卡!要缓存!
肯定是大大的cf了
页面规则
cloudflare默认回源,要写页面规则才会对页面缓存,cf一个域名免费3条规则
这样基本把wordpress缓存好了
还有Cache Rules
cache rules可以定义绕过缓存,把页面规则没绕过的也加进去,比如wp-admin和preview=true
再加cookie跳过规则,避免blog登录后的主页被缓存进去被别人看到头像
nginx的wp supper cache规则
# WP Super Cache 规则
#嗯~ o(* ̄▽ ̄*)o这段不知道是从哪看到的了
set $cache_uri $request_uri;
set $nginx_static 'BYPASS For File';
if ($request_method = POST)
{
set $cache_uri 'null cache';
set $nginx_static 'BYPASS For POST';
}
if ($query_string != "")
{
set $cache_uri 'null cache';
set $nginx_static 'BYPASS For Query';
}
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)")
{
set $cache_uri 'null cache';
set $nginx_static 'BYPASS For URL';
}
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in|woocommerce_items_in_cart|woocommerce_cart_hash|wptouch_switch_toogle")
{
set $cache_uri 'null cache';
set $nginx_static 'BYPASS For Cookie';
}
if (-f $document_root/wp-content/cache/supercache/$http_host/$cache_uri/index-https.html)
{
set $nginx_static 'HIT';
}
if (-f $document_root/wp-content/cache/supercache/$http_host/$cache_uri/index.html)
{
set $nginx_static 'HIT';
}
location /
{
try_files /wp-content/cache/supercache/$http_host/$cache_uri/index-https.html /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?$args;
}
add_header Nginx-cache-Status $nginx_static;
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
location ~ .*\.(gif|jpg|jpeg|png|webp|bmp|flv|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css)?$ {
expires 7d;
access_log off;
}
结果
配置完后注销登录就能在标头看到效果
Comments NOTHING