From ca5e74ee9836be819a344af0fbbcdce04f953401 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 12 Aug 2026 12:54:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=9D=99=E6=80=81=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E5=8F=91=E5=B8=83=E5=90=8E=E4=B8=8D=E7=94=9F=E6=95=88?= =?UTF-8?q?:=20/umd/=E7=BC=93=E5=AD=98=E7=AD=96=E7=95=A5=E4=BB=8Eimmutable?= =?UTF-8?q?=E6=94=B9=E4=B8=BAno-cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 构建产物文件名不带内容哈希,一年免验证的缓存策略导致每次蓝绿发布后 浏览器和CDN都会继续吃旧版本,用户需要清缓存或开无痕窗口才能看到更新。 改为no-cache后浏览器/CDN每次都会带条件请求向源站确认,未变化时只是 一次很快的304,一旦文件真的变了会立刻拿到新内容,不再需要手动清缓存。 --- docker/nginx.conf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docker/nginx.conf b/docker/nginx.conf index 54699d93..f02a7bc2 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -11,8 +11,11 @@ server { try_files $uri $uri/ /index.html; } + # Filenames here aren't content-hashed, so a long/immutable cache would keep + # serving a stale bundle after every deploy. Force revalidation instead: + # cheap 304s when unchanged, immediate pickup of new content when not. location /umd/ { - add_header Cache-Control "public, max-age=31536000, immutable"; + add_header Cache-Control "no-cache"; } location /img/ {