修复静态资源发布后不生效: /umd/缓存策略从immutable改为no-cache

构建产物文件名不带内容哈希,一年免验证的缓存策略导致每次蓝绿发布后
浏览器和CDN都会继续吃旧版本,用户需要清缓存或开无痕窗口才能看到更新。
改为no-cache后浏览器/CDN每次都会带条件请求向源站确认,未变化时只是
一次很快的304,一旦文件真的变了会立刻拿到新内容,不再需要手动清缓存。
This commit is contained in:
Your Name
2026-08-12 12:54:41 +08:00
parent 111d9040a7
commit ca5e74ee98
+4 -1
View File
@@ -11,8 +11,11 @@ server {
try_files $uri $uri/ /index.html; 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/ { location /umd/ {
add_header Cache-Control "public, max-age=31536000, immutable"; add_header Cache-Control "no-cache";
} }
location /img/ { location /img/ {