王一君Mew | 记录生活 分享技术

Typecho专用的CDN缓存规则

前言

首先感谢笔记堡 小白也能懂的CDN缓存配置:哪些参数该留,哪些该删? 提供的CDN保留参数 ::(花心)

虽说这样可以测速变绿,但是其他页面没有缓存 ::(委屈)

笔记堡的Itdog测速结果网站首页测速网站文章页测速

如你所见,其他页面没有缓存,假如某些人攻击你的网站,很可能刚开始就红了,而且这位博主使用的CDN还没有防御验证 ::(你懂的)
我结合了这位博主的CDN保留参数,弄了一个完美适配Typecho缓存规则
Tips:你需要使用带有“自定义缓存规则”的CDN,例如:cloudflare、阿里云ESA等
总共需要三个规则,其中有两个需要跳过缓存,一个需要缓存

缓存一:缓存所有页面

(starts_with(http.request.full_uri, "https://你的网址/") and not http.cookie contains "__typecho_authCode" and not http.cookie contains "__typecho_uid" and not http.cookie contains "__typecho_remember_") or (starts_with(http.request.full_uri, "https://你的网址/usr/uploads"))


缓存配置这样填

对查询字符串排序选择:是
查询字符串填写笔记堡的

size
type
format
version
w
h
id
page
cid
aid
lang
device
search
s
category
action
theme
tag
order
sort
Joe_Article_Views
Joe_Baidu_Record
缓存二:后台、搜索不缓存

(starts_with(http.request.full_uri, "https://你的网址/admin/")) or (starts_with(http.request.full_uri, "https://你的网址/search/"))

Tips:把“admin”改成你的实际后台路径

缓存配置这样填

缓存二:登录评论不缓存

(starts_with(http.request.full_uri, "https://你的网址/") and http.cookie contains "__typecho_authCode" and http.cookie contains "__typecho_uid") or (starts_with(http.request.full_uri, "https://你的网址/") and http.cookie contains "__typecho_remember_")


缓存配置这样填

OK了,你现在已经配置完成了,使用 Itdog 测速看看吧 ::(滑稽)

本站的Itdog测速结果网站首页测速网站文章页测速

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »