Repository navigation
feat(pwa): bound precache to app shell, route optional assets to expi… - #234
legend-esc wants to merge 1 commit into
Conversation
…ring runtime cache
|
@legend-esc Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
@legend-esc is attempting to deploy a commit to the truthixify's projects Team on Vercel. A member of the Team first needs to authorize it. |
truthixify
left a comment
There was a problem hiding this comment.
The optional-JS runtime route never matches: Workbox RegExpRoute evaluates the full URL href, so /^/assets/.*.js$/ cannot match https://host/assets/file.js. At the same time all JavaScript is removed from the precache, including the entry bootstrap; after first installation that bootstrap was fetched before the new worker controlled the page, so the first offline reload can fail. Match on url.pathname (or use a non-anchored safe same-origin route), keep the critical bootstrap in the app shell, and add a browser test covering first install followed immediately by offline reload.
Closes #215
Summary
Bounds the PWA precache to the application shell only, dropping precached assets from 200 entries (~9.66 MiB) to 18 entries (~110 KiB). Optional chain SDK chunks and media assets are no longer precached; they are lazily loaded and kept in bounded, expiring runtime caches instead.
Changes
vite.config.tsinjectManifest.globPatternsnow matches only the app shell:index.html,assets/*.css, favicons,apple-touch-icon.png,manifest.webmanifest.maximumFileSizeToCacheInBytes: 4 MiBoverride that accommodated heavy chunks; those chunks now go to runtime cache with expiration.src/sw/app-sw.tsCacheFirstroutes:/assets/*.js): max 60 entries, 7-day TTL (entry bootstrap, route chunks, chain SDKs).*.png|jpg|jpeg|svg|gif|webp|ico): max 40 entries, 30-day TTL (icons, OG image, logos).src/lib/swCache.tsCACHE_VERSION1 → 2 (cache schema migration).assetsandimagestoCACHE_KINDS; v1 caches are purged on activation.src/lib/swCache.test.tsVerification
pnpm build(tsc + vite): green, precache 18 entries / 109.76 KiB.prettier --check: clean.vitest run src/lib/swCache.test.ts: 10/10 pass.af78566ondevelop; feature branchfeat/wave10-pwa-bounded-precachepushed to origin.Behavior covered
maxEntries+maxAgeSeconds; v1→v2 migration releases legacy caches on activation.