perf(Caddy): 添加静态资源长期缓存配置
- 为 /assets/* 设置 1 年缓存 + immutable 标记 - 包含 logo.png 和 favicon.ico - 移除可能干扰缓存的 Pragma/Expires 头 效果: - 浏览器缓存命中后不再发送请求 - Cloudflare CDN 可正确缓存静态资源 - 重复访问页面秒开 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -33,6 +33,22 @@
|
|||||||
|
|
||||||
# 修改为你的域名
|
# 修改为你的域名
|
||||||
example.com {
|
example.com {
|
||||||
|
# =========================================================================
|
||||||
|
# 静态资源长期缓存(高优先级,放在最前面)
|
||||||
|
# 带 hash 的文件可以永久缓存,浏览器和 CDN 都会缓存
|
||||||
|
# =========================================================================
|
||||||
|
@static {
|
||||||
|
path /assets/*
|
||||||
|
path /logo.png
|
||||||
|
path /favicon.ico
|
||||||
|
}
|
||||||
|
header @static {
|
||||||
|
Cache-Control "public, max-age=31536000, immutable"
|
||||||
|
# 移除可能干扰缓存的头
|
||||||
|
-Pragma
|
||||||
|
-Expires
|
||||||
|
}
|
||||||
|
|
||||||
# =========================================================================
|
# =========================================================================
|
||||||
# TLS 安全配置
|
# TLS 安全配置
|
||||||
# =========================================================================
|
# =========================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user