refactor: 静态资源缓存破坏改为文件级哈希,重启不刷新未修改文件的缓存

- 启动时计算每个 JS/CSS 的 SHA-1 前 8 位作为版本号
- 文件不变则哈希不变,浏览器继续用缓存,重启零压力
- 替换全局 AssetVersion 为 assetV 模板函数,按文件路径查询哈希
- 移除 BuildPageData 中的全局版本号注入
This commit is contained in:
2026-05-31 01:53:17 +08:00
parent b8658712bb
commit d3e5cbe18b
18 changed files with 124 additions and 37 deletions

View File

@ -6,6 +6,8 @@ import (
"os"
"path/filepath"
"strings"
"metazone.cc/metalab/internal/common"
)
// TemplateRoot 模板根目录配置
@ -21,6 +23,7 @@ func LoadTemplates(roots ...TemplateRoot) (*template.Template, error) {
"add": func(a, b int) int { return a + b },
"subtract": func(a, b int) int { return a - b },
"formatTTL": formatTTL,
"assetV": common.AssetV,
}
t := template.New("").Funcs(funcMap)
for _, root := range roots {