From 38ad2db7a75250550e9972c481eede14ef8d4ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E7=BB=A7=E9=A3=8E?= <1914007838@qq.com> Date: Tue, 25 Jun 2024 10:17:36 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=E5=A2=9E=E5=8A=A0nginx=E4=B8=8D=E7=BC=93?= =?UTF-8?q?=E5=AD=98index.html=E9=85=8D=E7=BD=AE=EF=BC=8C=E6=90=AD?= =?UTF-8?q?=E9=85=8D=E5=89=8D=E7=AB=AF=E7=89=88=E6=9C=AC=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=8A=9F=E8=83=BD=E4=BD=BF=E7=94=A8=EF=BC=88?= =?UTF-8?q?=E4=B8=8D=E5=8A=A0=E6=AD=A4=E9=85=8D=E7=BD=AE=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E4=BC=9A=E5=AF=BC=E8=87=B4=E7=94=A8=E6=88=B7=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E5=90=8E=E8=BF=98=E6=98=AF=E6=97=A7=E7=89=88=E6=9C=AC=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker_env/nginx/my-80.conf | 4 ++++ docker_env/nginx/my.conf | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/docker_env/nginx/my-80.conf b/docker_env/nginx/my-80.conf index e50bdc4..98d33bd 100644 --- a/docker_env/nginx/my-80.conf +++ b/docker_env/nginx/my-80.conf @@ -7,6 +7,10 @@ server { index index.html index.htm; root /usr/share/nginx/html; try_files $uri $uri/ /index.html; + # 禁止缓存html文件,避免前端页面不及时更新,需要用户手动刷新的情况 + if ($request_uri ~* "^/$|^/index.html|^/index.htm") { + add_header Cache-Control "no-store"; + } } location ~ ^/api/ { diff --git a/docker_env/nginx/my.conf b/docker_env/nginx/my.conf index 178d979..dd6b333 100644 --- a/docker_env/nginx/my.conf +++ b/docker_env/nginx/my.conf @@ -11,6 +11,10 @@ server { real_ip_header X-Forwarded-For; root /usr/share/nginx/html; index index.html index.php index.htm; + # 禁止缓存html文件,避免前端页面不及时更新,需要用户手动刷新的情况 + if ($request_uri ~* "^/$|^/index.html|^/index.htm") { + add_header Cache-Control "no-store"; + } } location /api/ {