Cloudflare Cache Rules 与源站 Web 服务器设置的一些可能组合包括:
例如,在源站 Web 服务器上创建 /static/ 子目录,并创建匹配以下表达式的 Cache Everything Cache Rule:
- 使用 Expression Builder:
Hostname contains "example.com" AND URI Path starts with "/static" - 使用 Expression Editor:
(http.host contains "example.com" and starts_with(http.request.uri.path, "/static"))
例如,在源站 Web 服务器上为资源创建 .shtml 文件扩展名,并创建匹配以下表达式的 Cache Everything Cache Rule:
- 使用 Expression Builder:
Hostname contains "example.com" AND URI Path ends with ".shtml" - 使用 Expression Editor:
(http.host contains "example.com" and ends_with(http.request.uri.path, ".shtml"))
例如,在源站 Web 服务器上为资源添加 static=true 查询字符串,并创建匹配以下表达式的 Cache Everything Cache Rule:
- 使用 Expression Builder:
Hostname contains "example.com" AND URI Query String contains "static=true" - 使用 Expression Editor:
(http.host contains "example.com" and http.request.uri.query contains "static=true")
匹配 Cache Everything Cache Rule 的资源,如果源站 Web 服务器发送 max-age=0、private、no-cache 的 Cache-Control 标头,或 Expires 标头已过期,仍然不会被缓存。在 Cache Everything Cache Rule 中包含 Edge Cache TTL 设置,以额外覆盖源站 Web 服务器的 Cache-Control 标头。