fix(nginx): /articles/ 与 index.html 禁用启发式缓存,修复新增文章用户端报「没有找到这篇文章」
This commit is contained in:
1 parent
8d0c86076f
commit
8689a350e3
2 files changed
+19
-1
No files matched your search
+7
-1
@@ -6,7 +6,13 @@
|
||||
|
||||
## 2026-11-12
|
||||
|
||||
### 🧩 新增「MCP 使用说明」教程 + 顶栏菜单
|
||||
### 🐛 修复:文章列表被浏览器缓存导致「没有找到这篇文章」
|
||||
- 根因:`/articles/` 下的 `index.json`/`.md` 此前无 `Cache-Control`,浏览器走启发式缓存,新增文章后用户端仍读旧列表,`ArticleDetail` 找不到条目即报「没有找到这篇文章:<slug>」
|
||||
- nginx 修复:`location /articles/` 与 `location = /index.html` 加 `Cache-Control: no-cache`(每次协商校验,命中 304 不费流量;入口页不缓存可避免旧 html 引用已失效的 chunk hash);`/homeAssets/` 30 天 immutable 长缓存保留不变
|
||||
- 验证:线上三类响应头均为 `Cache-Control: no-cache`,构建产物仍 `max-age=2592000 + public, immutable`
|
||||
- 注意:已缓存旧列表的浏览器需强刷一次完成迁移,之后自动始终最新
|
||||
|
||||
### ✨ 新增「MCP 使用说明」教程
|
||||
|
||||
- 新文章 `public/articles/mcp-guide.md`(11.5KB 九节):MCP 概念与米剪 10 工具总览、端点与 Bearer 令牌(fail-closed/401)、**四种客户端接入模板**(Claude Desktop mcp-remote / Claude Code `claude mcp add` / Cursor mcp.json / Hermes config.yaml)、工具逐个详解(参数与默认值按 `mcp/server.py` 源码核实:`grab_url` 12000 字截断、`generate_script` 60 秒×4.5 字、`tts` 默认晓晓音色 ≤2000 字、`create_video_project` 30 图上限/160×120 门禁)、一句话生成视频实战链、curl 握手自检、`.env` 自部署配置、8 条常见问题
|
||||
- 顶栏菜单加「**MCP 使用说明**」(`Header.tsx` nav,置于「使用教程」后,当前页自动高亮)
|
||||
|
||||
+12
@@ -41,6 +41,18 @@ server {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# 文章目录禁止启发式缓存:index.json 更新(新增文章/改标题)后必须立即可见,
|
||||
# 否则浏览器按 ETag/Last-Modified 自行推断新鲜度会命中旧列表 → 详情页报
|
||||
# 「没有找到这篇文章」。no-cache = 每次协商校验(命中 304,不费流量)。
|
||||
location /articles/ {
|
||||
add_header Cache-Control "no-cache";
|
||||
}
|
||||
|
||||
# 入口页同样不缓存:旧 index.html 会引用已不存在的旧 chunk hash
|
||||
location = /index.html {
|
||||
add_header Cache-Control "no-cache";
|
||||
}
|
||||
|
||||
# 长缓存带 hash 的构建产物
|
||||
location /homeAssets/ {
|
||||
expires 30d;
|
||||
|
||||
Reference in new issue
Block a user