Skip to content

Commit abc22c5

Browse files
committed
fix(pwa): enable Workbox precaching and add Caddy cache-control headers
1 parent 4f9f313 commit abc22c5

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
default: patch
3+
---
4+
5+
Fix intermittent 401 errors when loading media after service worker restart. Service worker now expires cached authentication tokens after 60 seconds, forcing fresh token retrieval from the active page instead of using potentially stale persisted tokens.

Caddyfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616

1717
try_files {path} /index.html
1818

19+
# Content-hashed assets can be cached indefinitely — the filename changes on every build.
20+
header /assets/* Cache-Control "public, max-age=31536000, immutable"
21+
# Workbox SW must be revalidated on every load so the browser picks up updates.
22+
header /sw.js Cache-Control "no-cache"
23+
# index.html must not be cached so the browser always gets the latest app shell.
24+
header /index.html Cache-Control "no-cache"
25+
1926
# Required for Sentry browser profiling (JS Self-Profiling API)
2027
header Document-Policy "js-profiling"
2128
}

vite.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,11 @@ export default defineConfig(({ command }) => ({
176176
injectRegister: false,
177177
manifest: false,
178178
injectManifest: {
179-
injectionPoint: undefined,
179+
// element-call is a self-contained embedded app; exclude its large assets
180+
// from the SW precache manifest (they are not part of the Sable shell).
181+
globIgnores: ['public/element-call/**'],
182+
// The app's own crypto WASM and main bundle exceed the 2 MiB default.
183+
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024, // 10 MiB
180184
},
181185
devOptions: {
182186
enabled: true,

0 commit comments

Comments
 (0)