From f0351107ddfa3fee7e612acd069140321ef3d516 Mon Sep 17 00:00:00 2001 From: sagitchu Date: Sun, 5 Apr 2026 17:50:12 +0800 Subject: [PATCH] fix: frontend browser caching issue Disable caching for index.html and reduce static assets cache to 30d. --- vite-frontend/index.html | 3 +++ vite-frontend/nginx.conf | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/vite-frontend/index.html b/vite-frontend/index.html index be002a4..5a1e061 100644 --- a/vite-frontend/index.html +++ b/vite-frontend/index.html @@ -2,6 +2,9 @@ + + + diff --git a/vite-frontend/nginx.conf b/vite-frontend/nginx.conf index 76e1883..366fa57 100644 --- a/vite-frontend/nginx.conf +++ b/vite-frontend/nginx.conf @@ -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;