fix: SW 缓存导致页面不更新 — fetch 绕过 HTTP 缓存 + hydration 闪屏修复

- sw.js: HTML fetch 加 cache:"no-cache",避免从浏览器缓存拿旧页面
- ServiceWorkerRegistrar: 注册时 updateViaCache:"none",确保 SW 自身及时更新
- blindbox/page: 增加 hydrated 状态,防止 SSR/CSR 内容不一致导致闪屏
This commit is contained in:
2026-02-27 10:28:23 +08:00
parent beb2c632bb
commit 4cc9d66403
3 changed files with 7 additions and 5 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ self.addEventListener("fetch", (event) => {
// HTML pages: network-first, fallback to cache, then offline page
event.respondWith(
fetch(request)
fetch(request, { cache: "no-cache" })
.then((response) => {
const clone = response.clone();
caches.open(CACHE_NAME).then((cache) => cache.put(request, clone));