fix(deploy): prevent stale SPA entry caching
This commit is contained in:
@@ -11,6 +11,19 @@ server {
|
||||
return 200 "ok\n";
|
||||
}
|
||||
|
||||
# SPA 入口每次重新校验,避免发布后浏览器继续运行旧资源清单。
|
||||
location = /index.html {
|
||||
add_header Cache-Control "no-store, no-cache, must-revalidate" always;
|
||||
add_header Pragma "no-cache" always;
|
||||
add_header Expires "0" always;
|
||||
}
|
||||
|
||||
# Vite 产物文件名带内容哈希,可安全长期缓存。
|
||||
location /assets/ {
|
||||
try_files $uri =404;
|
||||
add_header Cache-Control "public, max-age=31536000, immutable" always;
|
||||
}
|
||||
|
||||
# 前端统一请求 /api,保持原始路径转发给 Gateway。
|
||||
location /api/ {
|
||||
client_max_body_size 55m;
|
||||
@@ -36,6 +49,7 @@ server {
|
||||
|
||||
# 支持 Vue Router history 路由直接刷新。
|
||||
location / {
|
||||
add_header Cache-Control "no-store, no-cache, must-revalidate" always;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user