From 6792ac8f17fd3bebaed0932e57dec82a4653494d Mon Sep 17 00:00:00 2001 From: AprilWind <2100166581@qq.com> Date: Fri, 12 Sep 2025 16:44:18 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20nginx=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=EF=BC=8C=E5=A2=9E=E5=BC=BA=E7=BC=93=E5=AD=98=E7=AD=96?= =?UTF-8?q?=E7=95=A5=E5=92=8C=E5=AE=89=E5=85=A8=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/docker/nginx/conf/nginx.conf | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/script/docker/nginx/conf/nginx.conf b/script/docker/nginx/conf/nginx.conf index 4b9b179ed..ce62aaccf 100644 --- a/script/docker/nginx/conf/nginx.conf +++ b/script/docker/nginx/conf/nginx.conf @@ -14,8 +14,11 @@ http { keepalive_timeout 65; # 限制body大小 client_max_body_size 100m; + client_body_buffer_size 128k; # 开启静态资源压缩 gzip_static on; + # 隐藏版本号 + server_tokens off; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' @@ -69,7 +72,24 @@ http { return 403; } + # hash 文件长缓存 + location ~* \.[a-f0-9]{8}\.(css|js)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + + # 图片/字体缓存 + location ~* \.(jpg|jpeg|png|gif|ico|svg|woff|woff2|ttf)$ { + expires 30d; + add_header Cache-Control "public"; + } + location / { + # HTML 页面不缓存 + add_header Cache-Control "no-cache, no-store, must-revalidate" always; + add_header Pragma "no-cache" always; + add_header Expires "0" always; + root /usr/share/nginx/html; # docker映射路径 不允许更改 try_files $uri $uri/ /index.html; index index.html index.htm; -- Gitee