fix(site): CSS/JS 内容 hash 版本号,根治边缘缓存样式不更新 - #66
Merged
Conversation
问题:styles.css/app.js 设了 max-age=86400,Cloudflare 边缘缓存旧版, 部署 CSS 改动后用户仍看到旧样式(详情页排版修复一度不可见)。 修复:HTML 引用改为 styles.css?v=<hash> / app.js?v=<hash>,hash 取文件 内容 sha256 前 10 位。内容变→URL 变→边缘按新 key 取新文件(立即生效); 内容不变→URL 不变→继续命中长缓存。HTML 本身 max-age=0 始终新鲜, 保证总是引用到最新版本号。 验证:重建 42 页,首页与详情页 CSS/JS 引用均带 ?v=hash。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
styles.css/app.js 加 ?v=<内容hash>,部署 CSS 改动后立即生效,绕过 Cloudflare max-age=86400 边缘缓存。