From a998ccd527b11acb7e80e76a393ba497fbb545dc Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Thu, 24 Sep 2026 18:47:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(nginx):=20production=20=E8=A1=A5=20index.ht?= =?UTF-8?q?ml=20no-cache=20=E7=B2=BE=E7=A1=AE=E5=9D=97=EF=BC=8C=E9=98=B2?= =?UTF-8?q?=E6=97=A7=E7=BC=93=E5=AD=98=E5=AF=BC=E8=87=B4=E5=8A=A8=E6=80=81?= =?UTF-8?q?=20import=20=E5=A4=B1=E8=B4=A5=20(#2031)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: xiaoxia Co-committed-by: xiaoxia --- deploy/configs/nginx-production.conf | 6 ++++++ infra/docker/nginx-production.conf | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/deploy/configs/nginx-production.conf b/deploy/configs/nginx-production.conf index 1944f8f1f..893f4072d 100644 --- a/deploy/configs/nginx-production.conf +++ b/deploy/configs/nginx-production.conf @@ -12,6 +12,12 @@ server { client_max_body_size 800m; # SPA routing - index.html 禁止缓存,确保每次获取最新版本 + location = /index.html { + add_header Cache-Control "no-cache, no-store, must-revalidate"; + add_header Pragma "no-cache"; + expires 0; + } + location / { try_files $uri /index.html; # HTML 文档(含 try_files 回退的 SPA 路由,如 /login /app/dashboard)一律 no-cache, diff --git a/infra/docker/nginx-production.conf b/infra/docker/nginx-production.conf index c5269f003..93e45515e 100755 --- a/infra/docker/nginx-production.conf +++ b/infra/docker/nginx-production.conf @@ -12,6 +12,13 @@ server { client_max_body_size 800m; + # SPA routing - index.html 禁止缓存,确保每次获取最新版本 + location = /index.html { + add_header Cache-Control "no-cache, no-store, must-revalidate"; + add_header Pragma "no-cache"; + expires 0; + } + # SPA routing - all routes to index.html # 注意:不能加 $uri/,否则 /assets 等与构建产物目录同名的路由会被当成目录访问,返回 403 location / {