From 3354369f6a9adfe45d6c74d4eb878cb220594c79 Mon Sep 17 00:00:00 2001 From: huanghaosheng <386998068@qq.com> Date: Tue, 20 Oct 2026 00:01:31 +0800 Subject: [PATCH] =?UTF-8?q?docs(DEPLOY):=20css/js=20=E4=B9=9F=E8=AE=BE=20C?= =?UTF-8?q?ache-Control=20no-cache=EF=BC=8C=E5=86=85=E5=AE=B9=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=90=8E=E6=99=AE=E9=80=9A=E5=88=B7=E6=96=B0=E5=8D=B3?= =?UTF-8?q?=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DEPLOY.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/DEPLOY.md b/DEPLOY.md index 22243f1..2e376fc 100644 --- a/DEPLOY.md +++ b/DEPLOY.md @@ -112,10 +112,14 @@ server { # 纯静态 + hash 路由:不需要任何 rewrite / History 回退规则, # 目录请求由 index 指令落到 index.html,其余交给默认静态处理。 - # HTML 不做强缓存,改完内容刷新即见;js/css 走 ETag 重新校验 + # HTML 不做强缓存,改完内容刷新即见;css/js 同理,仍走 ETag 重新校验(未变则 304) location ~* \.html?$ { add_header Cache-Control "no-cache"; } + + location ~* \.(css|js)$ { + add_header Cache-Control "no-cache"; + } } ``` @@ -295,7 +299,7 @@ docker exec 1Panel-openresty-XOJH /usr/local/openresty/nginx/sbin/nginx -t \ | 改了 conf 不生效 | 忘了 `-s reload`;或改错了目录(宿主机 `/opt/1panel/www/conf.d/`,不是容器里的路径) | | 页面 403 | conf 里 `root` 写成了宿主机路径,必须是容器视角的 `/www/sites/materials/index` | | 目录访问 403 而不是出 index | `index.html` 是否真的存在;`index index.html;` 是否在 | -| 内容更新了但页面没变 | 浏览器缓存;HTML 已设 `Cache-Control: no-cache`,硬刷新 `Ctrl+F5` | +| 内容更新了但页面没变 | 先确认服务器 `git -C /opt/1panel/www/sites/materials/index rev-parse --short HEAD` 是新提交;HTML/css/js 均已设 `Cache-Control: no-cache`,普通刷新即应重新校验,仍不对再硬刷新 `Ctrl+F5` | | 容器名对不上 | 1Panel 重建容器会换后缀:`docker ps --filter name=openresty` | ### 回滚