修复静态资源发布后不生效: /umd/缓存策略从immutable改为no-cache
构建产物文件名不带内容哈希,一年免验证的缓存策略导致每次蓝绿发布后 浏览器和CDN都会继续吃旧版本,用户需要清缓存或开无痕窗口才能看到更新。 改为no-cache后浏览器/CDN每次都会带条件请求向源站确认,未变化时只是 一次很快的304,一旦文件真的变了会立刻拿到新内容,不再需要手动清缓存。
This commit is contained in:
+4
-1
@@ -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/ {
|
||||
|
||||
Reference in New Issue
Block a user