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:
Jeff Emmett 2026-03-25 18:02:14 -07:00
parent 23083c32b0
commit dce608ae1b
4 changed files with 6 additions and 6 deletions

View File

@ -278,7 +278,7 @@ export function renderShell(opts: ShellOptions): string {
import '/shell.js';
// ── Service worker registration ──
if ("serviceWorker" in navigator && location.hostname !== "localhost") {
navigator.serviceWorker.register("/sw.js").catch(() => {});
navigator.serviceWorker.register("/sw.js?v=4").catch(() => {});
}
// ── Install prompt capture ──
window.addEventListener("beforeinstallprompt", (e) => {
@ -2113,7 +2113,7 @@ export function renderModuleLanding(opts: ModuleLandingOptions): string {
<script type="module">
import '/shell.js';
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});
try {
@ -2448,7 +2448,7 @@ export function renderSubPageInfo(opts: SubPageInfoOptions): string {
<script type="module">
import '/shell.js';
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});
try {

View File

@ -2613,7 +2613,7 @@
// Register service worker for offline support
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);
}).catch((err) => {
console.warn("[Canvas] Service worker registration failed:", err);

View File

@ -300,7 +300,7 @@
<script type="module">
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 { RStackAppSwitcher } from "@shared/components/rstack-app-switcher";

View File

@ -523,7 +523,7 @@
<script type="module">
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 { RStackAppSwitcher } from "@shared/components/rstack-app-switcher";