fix: frontend browser caching issue

Disable caching for index.html and reduce static assets cache to 30d.
This commit is contained in:
sagitchu
2026-04-05 17:50:12 +08:00
parent 101fd5805a
commit 930cc86614
2 changed files with 12 additions and 1 deletions
+9 -1
View File
@@ -45,10 +45,18 @@ http {
# 静态文件缓存
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
expires 30d;
add_header Cache-Control "public, immutable";
}
# HTML 文件不缓存
location ~* \.(?:htm|html)$ {
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
try_files $uri $uri/ /index.html;
}
# Vue Router的history模式支持
location / {
try_files $uri $uri/ /index.html;