ops(deploy): 一键部署脚本 tools/deploy.sh + deploy.md 同步 no-cache 缓存策略
- tools/deploy.sh:git pull --ff-only → rsync web/ → /var/www/soundgame (排除开发用文件)→ chown www-data → 线上冒烟(大厅/子站/301/Range)。 已在部署服务器实测全流程 PASS。 - docs/deploy.md:nginx 配置段同步为线上现行 no-cache 版本(原文档仍是 expires+public,照抄会把「部署后旧 JS 在浏览器滞留 24h」的坑重新引回), 并注明一键脚本入口。背景:2026-09-07 引擎句尾截断修复已正确部署, 但旧 audio.js 被 max-age=86400 public 缓存,用户 24h 内仍执行旧代码。
This commit is contained in:
+18
-6
@@ -41,7 +41,14 @@ Nginx 80/443
|
||||
|
||||
## 更新游戏文件
|
||||
|
||||
源码有改动后,在本机执行:
|
||||
上述流程已封装为一键脚本 `tools/deploy.sh`(git pull --ff-only + rsync +
|
||||
chown + 冒烟验证),在部署服务器上执行:
|
||||
|
||||
```bash
|
||||
bash tools/deploy.sh
|
||||
```
|
||||
|
||||
等价的手动步骤(源码有改动后,在本机执行):
|
||||
|
||||
```bash
|
||||
sudo rsync -a --delete \
|
||||
@@ -52,7 +59,9 @@ sudo rsync -a --delete \
|
||||
sudo chown -R www-data:www-data /var/www/soundgame
|
||||
```
|
||||
|
||||
静态文件即时生效,不必 reload Nginx。改了 `soundgame.conf` 才需要:
|
||||
静态文件即时生效,不必 reload Nginx;配合全站 `no-cache` 缓存策略,用户下次
|
||||
打开页面即可拿到新文件(2026-09-07 之前 js/css 曾是 24h 强缓存,部署后旧 JS
|
||||
在用户浏览器里滞留一天,表现为"改了却没生效")。改了 `soundgame.conf` 才需要:
|
||||
|
||||
```bash
|
||||
sudo nginx -t && sudo systemctl reload nginx
|
||||
@@ -111,6 +120,11 @@ server {
|
||||
root /var/www/soundgame;
|
||||
index index.html;
|
||||
|
||||
# 全站 no-cache:可缓存但必须回源验证(ETag→304)。
|
||||
# 2026-09-07 教训:此前 js/css 是 max-age=86400 public,引擎修复部署后
|
||||
# 用户浏览器 24h 内仍执行旧 audio.js,句尾截断"修不好"。静态小站回源
|
||||
# 验证成本可忽略,换取每次部署立即生效。
|
||||
add_header Cache-Control "no-cache";
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
add_header Referrer-Policy strict-origin-when-cross-origin;
|
||||
|
||||
@@ -123,15 +137,13 @@ server {
|
||||
}
|
||||
|
||||
location ~* \.(ogg|m4a|mp3|wav|png|jpg|jpeg|gif|ico|svg|woff2?)$ {
|
||||
expires 7d;
|
||||
add_header Cache-Control "public";
|
||||
add_header Cache-Control "no-cache";
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location ~* \.(js|css)$ {
|
||||
expires 1d;
|
||||
add_header Cache-Control "public";
|
||||
add_header Cache-Control "no-cache";
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user