cloudflare缓存wordpress的页面规则

使用 cloudflare page rules 设置缓存 cache wordpress, 加速网站访问速度

规则一: 不缓存wp-admin目录


localhost.com/wp-admin*
Cache Level = Bypass
Security Level = High

规则二: 不缓存文章预览


localhost.com/*preview=true*
Cache Level = Bypass

规则三: 缓存所有文件


localhost.com/*
Browser Cache TTL = 30 minutes
Cache Level = Cache Everything
Edge Cache TTL = 2 hours

可选规则: CDN缓存301跳转


localhost.com
Forwarding URL = 301 - Permanent Redirect
https://www.localhost.com

其他规则: 仅缓存首页


https://www.localhost.com
Browser Cache TTL = 30 minutes
Cache Level = Cache Everything
Edge Cache TTL = 2 hours

其他规则: 绕过缓存


(http.request.full_uri eq "https://example.com/wp-admin*") or (http.request.full_uri eq "https://example.com/*preview=true*") or (http.request.full_uri eq "https://example.com/user/*") or (http.request.full_uri eq "https://example.com/?s=*") or (starts_with(http.request.full_uri, "https://example.com/") and http.cookie contains "wp-") or (starts_with(http.request.full_uri, "https://example.com/") and http.cookie contains "wordpress_sec_") or (starts_with(http.request.full_uri, "https://example.com/") and http.cookie contains "wordpress_logged_in") or (starts_with(http.request.full_uri, "https://example.com/") and http.cookie contains "comment_") or (starts_with(http.request.full_uri, "https://example.com/") and http.cookie contains "woocommerce_")

推荐打开:缓存密钥-缓存欺骗盔甲,更新时不提供过时的内容(从缓存获取内容)。
规则顺序:缓存在前,绕过缓存在后

安装Change wp-admin login 插件


使用这个插件可以重定向/wp-login.php到自定义URL绕过缓存, 比如/wp-adminadmin
https://wordpress.org/plugins/change-wp-admin-login/
https://downloads.wordpress.org/plugin/change-wp-admin-login.zip

附送wordpress蜘蛛访问robots.txt规则


User-agent: *
Disallow: /wp-admin/
Disallow: /*/comment-page-*
Disallow: /*?replytocom=*
Disallow: /*/trackback
Disallow: /feed
Disallow: /*/feed
Disallow: /comments/feed
Disallow: /?s=*
Disallow: /*/?s=*\
Disallow: /attachment/
Disallow: /author/
Disallow: /user/

附送本站绕过规则

(starts_with(http.request.full_uri, "https://www.livelu.com/") and http.cookie contains "__typecho") or (http.request.full_uri eq "https://www.livelu.com/admin/*") 

此处评论已关闭