Cloudflare缓存全站设置

本文参考了萌精灵的文章和cloudflare官方说明。

CloudFlare 默认只对静态资源进行缓存。动态资源是默认不缓存的。如果你的内容基本是静态的或者不在意实时更新的话,可以使用 CloudFlare 的页面规则设置缓存所有内容。免费用户可以设置3条页面规则,Pro 用户可以使用 30 条规则。

1、添加新的页面规则。

cf_1.png


2、设置URL,然后“Cache Level”就选择 “Cache Everything”,设置好后点击“Save and Deploy”即可

cf_2.png


注:
1、Cache Level为缓存类型,这里为“Cache Everything”。
2、Edge Cache TTL 为 CloudFlare 多久去你的原始服务器检查更新。

3、把后台管理设置为 Bypass,否则会进不去后台。同时把这条规则排在前一条规则(Cache Everything)的前面。

cf_3.png

关于星号*泛匹配的几个tips:

  • To match both http and https, just write example.com. It is not necessary to write *example.com.
  • To match every page on a domain, write example.com/*. Just writing example.com won’t work.
  • To match every page on a domain and it’s subdomains, write *example.com/*. Just writing example.com won’t work.
  • A wildcard (*) in a Page Rule URL will match even if no characters are present, and may include any part of the URL, including the query string.

引用:

https://www.moeelf.com/archives/22.html
https://support.cloudflare.com/hc/en-us/articles/218411427

本文链接: https://www.168itw.com/web-server/cloudflare-caching/
转载请注明转载自:168itw

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注