fix: cache-bust sw.js registration + no-cache header for SW/manifest
- Add ?v=4 to all SW registration URLs to bypass stale CF CDN cache - Set Cache-Control: no-cache for sw.js and manifest.json so future SW updates are never blocked by CDN caching Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
23083c32b0
commit
dce608ae1b
|
|
@ -278,7 +278,7 @@ export function renderShell(opts: ShellOptions): string {
|
||||||
import '/shell.js';
|
import '/shell.js';
|
||||||
// ── Service worker registration ──
|
// ── Service worker registration ──
|
||||||
if ("serviceWorker" in navigator && location.hostname !== "localhost") {
|
if ("serviceWorker" in navigator && location.hostname !== "localhost") {
|
||||||
navigator.serviceWorker.register("/sw.js").catch(() => {});
|
navigator.serviceWorker.register("/sw.js?v=4").catch(() => {});
|
||||||
}
|
}
|
||||||
// ── Install prompt capture ──
|
// ── Install prompt capture ──
|
||||||
window.addEventListener("beforeinstallprompt", (e) => {
|
window.addEventListener("beforeinstallprompt", (e) => {
|
||||||
|
|
@ -2113,7 +2113,7 @@ export function renderModuleLanding(opts: ModuleLandingOptions): string {
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import '/shell.js';
|
import '/shell.js';
|
||||||
if ("serviceWorker" in navigator && location.hostname !== "localhost") {
|
if ("serviceWorker" in navigator && location.hostname !== "localhost") {
|
||||||
navigator.serviceWorker.register("/sw.js").catch(() => {});
|
navigator.serviceWorker.register("/sw.js?v=4").catch(() => {});
|
||||||
}
|
}
|
||||||
document.querySelector('rstack-app-switcher')?.setModules(${moduleListJSON});
|
document.querySelector('rstack-app-switcher')?.setModules(${moduleListJSON});
|
||||||
try {
|
try {
|
||||||
|
|
@ -2448,7 +2448,7 @@ export function renderSubPageInfo(opts: SubPageInfoOptions): string {
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import '/shell.js';
|
import '/shell.js';
|
||||||
if ("serviceWorker" in navigator && location.hostname !== "localhost") {
|
if ("serviceWorker" in navigator && location.hostname !== "localhost") {
|
||||||
navigator.serviceWorker.register("/sw.js").catch(() => {});
|
navigator.serviceWorker.register("/sw.js?v=4").catch(() => {});
|
||||||
}
|
}
|
||||||
document.querySelector('rstack-app-switcher')?.setModules(${moduleListJSON});
|
document.querySelector('rstack-app-switcher')?.setModules(${moduleListJSON});
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -2613,7 +2613,7 @@
|
||||||
|
|
||||||
// Register service worker for offline support
|
// Register service worker for offline support
|
||||||
if ("serviceWorker" in navigator && window.location.hostname !== "localhost") {
|
if ("serviceWorker" in navigator && window.location.hostname !== "localhost") {
|
||||||
navigator.serviceWorker.register("/sw.js").then((reg) => {
|
navigator.serviceWorker.register("/sw.js?v=4").then((reg) => {
|
||||||
console.log("[Canvas] Service worker registered, scope:", reg.scope);
|
console.log("[Canvas] Service worker registered, scope:", reg.scope);
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.warn("[Canvas] Service worker registration failed:", err);
|
console.warn("[Canvas] Service worker registration failed:", err);
|
||||||
|
|
|
||||||
|
|
@ -300,7 +300,7 @@
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
if ("serviceWorker" in navigator && location.hostname !== "localhost") {
|
if ("serviceWorker" in navigator && location.hostname !== "localhost") {
|
||||||
navigator.serviceWorker.register("/sw.js").catch(() => {});
|
navigator.serviceWorker.register("/sw.js?v=4").catch(() => {});
|
||||||
}
|
}
|
||||||
import { RStackIdentity } from "@shared/components/rstack-identity";
|
import { RStackIdentity } from "@shared/components/rstack-identity";
|
||||||
import { RStackAppSwitcher } from "@shared/components/rstack-app-switcher";
|
import { RStackAppSwitcher } from "@shared/components/rstack-app-switcher";
|
||||||
|
|
|
||||||
|
|
@ -523,7 +523,7 @@
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
if ("serviceWorker" in navigator && location.hostname !== "localhost") {
|
if ("serviceWorker" in navigator && location.hostname !== "localhost") {
|
||||||
navigator.serviceWorker.register("/sw.js").catch(() => {});
|
navigator.serviceWorker.register("/sw.js?v=4").catch(() => {});
|
||||||
}
|
}
|
||||||
import { RStackIdentity, isAuthenticated, getAccessToken } from "@shared/components/rstack-identity";
|
import { RStackIdentity, isAuthenticated, getAccessToken } from "@shared/components/rstack-identity";
|
||||||
import { RStackAppSwitcher } from "@shared/components/rstack-app-switcher";
|
import { RStackAppSwitcher } from "@shared/components/rstack-app-switcher";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue