fix(nginx): production 补 index.html no-cache 精确块,防旧缓存导致动态 import 失败 #2031
Reference in New Issue
Block a user
Delete Branch "fix/nginx-index-nocache"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
问题
发版后浏览器缓存旧 index.html,引用已被删除的带 hash 的 JS chunk,导致动态 import 失败、页面白屏/报错。
改动
给 production nginx 配置补上精确匹配
/index.html的 no-cache 头块(staging 配置此前已有):deploy/configs/nginx-production.conf:补精确块(放在 location / 之前,优先匹配)infra/docker/nginx-production.conf:同上(Dockerfile 实际 COPY 到容器使用的配置)deploy/configs/nginx-staging.conf和infra/docker/nginx-staging.conf:此前已存在该精确块,无需改动/assets/*.js、*.css、图片字体等继续由expires 1y + immutable长缓存,不受影响效果
https://域名/index.html时强制不缓存,每次请求都拿最新版本(ETag/Last-Modified 协商)验证
nginx -t语法检查通过(待镜像构建后自动验证)🚀 预览环境已部署
🗑️ 预览环境已清理
PR #2031 已关闭或合并,对应的预览环境已被清理。