From 74a3c74514652d55d14f4daf7ae6bca4d79165c3 Mon Sep 17 00:00:00 2001 From: yangjianbo Date: Fri, 16 Jan 2026 22:49:05 +0800 Subject: [PATCH] =?UTF-8?q?perf(Caddy):=20=E6=B7=BB=E5=8A=A0=E9=9D=99?= =?UTF-8?q?=E6=80=81=E8=B5=84=E6=BA=90=E9=95=BF=E6=9C=9F=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为 /assets/* 设置 1 年缓存 + immutable 标记 - 包含 logo.png 和 favicon.ico - 移除可能干扰缓存的 Pragma/Expires 头 效果: - 浏览器缓存命中后不再发送请求 - Cloudflare CDN 可正确缓存静态资源 - 重复访问页面秒开 Co-Authored-By: Claude Opus 4.5 --- deploy/Caddyfile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/deploy/Caddyfile b/deploy/Caddyfile index 3aeef51a..e5636213 100644 --- a/deploy/Caddyfile +++ b/deploy/Caddyfile @@ -33,6 +33,22 @@ # 修改为你的域名 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 安全配置 # =========================================================================