Skip to content

feat(pwa): bound precache to app shell, route optional assets to expi… - #234

Open
legend-esc wants to merge 1 commit into
wraith-protocol:developfrom
legend-esc:feat/wave10-pwa-bounded-precache
Open

legend-esc wants to merge 1 commit into
wraith-protocol:developfrom
legend-esc:feat/wave10-pwa-bounded-precache

Conversation

@legend-esc

Copy link
Copy Markdown

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.ts

  • injectManifest.globPatterns now matches only the app shell: index.html, assets/*.css, favicons, apple-touch-icon.png, manifest.webmanifest.
  • Removed the maximumFileSizeToCacheInBytes: 4 MiB override that accommodated heavy chunks; those chunks now go to runtime cache with expiration.

src/sw/app-sw.ts

  • Added two expiring runtime CacheFirst routes:
    • assets (/assets/*.js): max 60 entries, 7-day TTL (entry bootstrap, route chunks, chain SDKs).
    • images (*.png|jpg|jpeg|svg|gif|webp|ico): max 40 entries, 30-day TTL (icons, OG image, logos).
  • Vite content-hashed filenames bust old entries automatically on deploy.

src/lib/swCache.ts

  • Bumped CACHE_VERSION 1 → 2 (cache schema migration).
  • Added assets and images to CACHE_KINDS; v1 caches are purged on activation.

src/lib/swCache.test.ts

  • Added tests: bounded runtime cache kinds exist; v1 caches purged on v2 activation (storage-pressure release).

Verification

  • pnpm build (tsc + vite): green, precache 18 entries / 109.76 KiB.
  • prettier --check: clean.
  • vitest run src/lib/swCache.test.ts: 10/10 pass.
  • Commit af78566 on develop; feature branch feat/wave10-pwa-bounded-precache pushed to origin.

Behavior covered

  • First install: shell assets precached; chunks/media load on demand.
  • Offline reload: shell served from precache; previously-visited chunks/media served from expiring runtime caches.
  • Update: new build generates new hashed asset URLs; old cache entries expire/bust naturally; v2 activation purges v1 caches.
  • Storage pressure: caches bounded by maxEntries + maxAgeSeconds; v1→v2 migration releases legacy caches on activation.

@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@vercel

vercel Bot commented Oct 17, 2026

Copy link
Copy Markdown

@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 truthixify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Wave 10] Bound the PWA precache instead of caching the full 9.66 MB build

2 participants