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:
@@ -5,7 +5,7 @@ import { useEffect } from "react";
|
||||
export default function ServiceWorkerRegistrar() {
|
||||
useEffect(() => {
|
||||
if ("serviceWorker" in navigator) {
|
||||
navigator.serviceWorker.register("/sw.js").catch(() => {});
|
||||
navigator.serviceWorker.register("/sw.js", { updateViaCache: "none" }).catch(() => {});
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user