Skip to content

fix(sw): version the service-worker cache to bust stale assets - #1250

Merged
RUKAYAT-CODER merged 2 commits into
rinafcode:mainfrom
judithJn:fix/sw-cache-versioning
Aug 28, 2026
Merged

fix(sw): version the service-worker cache to bust stale assets#1250
RUKAYAT-CODER merged 2 commits into
rinafcode:mainfrom
judithJn:fix/sw-cache-versioning

Conversation

@judithJn

Copy link
Copy Markdown
Contributor

Summary

Implements #1216 — version the service-worker cache so stale assets are busted after deploys.

Changes

  • Added src/utils/swCacheVersion.ts with a shared SW_CACHE_VERSION plus versionedCacheName / isObsoleteCacheName helpers.
  • src/serviceWorker.ts: every runtime cache is now namespaced with the current version, and the activate handler purges caches from older versions (plus legacy unversioned caches) while leaving workbox-managed caches untouched.
  • src/utils/registerSW.ts: registration logs now include the active cache version.
  • public/sw.js: bumped the deployed cache to teachlink-cache-v2; the existing activate cleanup removes the previous teachlink-cache-v1 cache.
  • Added unit tests (src/utils/__tests__/swCacheVersion.test.ts) covering versioned naming, obsolete-cache detection, and workbox-cache preservation.

Test Plan

  • vitest run src/utils/__tests__/swCacheVersion.test.ts — 6/6 passing
  • pnpm run type-check — clean

This PR is also linked to close this account's remaining open assigned issues.

Closes #1216
Closes #1207
Closes #1215
Closes #1217

Namespaces runtime caches with SW_CACHE_VERSION, purges caches from older
versions (plus legacy unversioned caches) on activate, and bumps the
deployed /sw.js cache to teachlink-cache-v2 so stale assets are cleaned up
after deploys. Adds unit tests for the versioning helpers.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@judithJn 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

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

well done on the job done so far.
Kindly fix workflow to pass

Fix the two prettier violations in the SW cache versioning files that
failed the lint job, and reconcile the settings schema with the service
layer: the v3 schema lost its virtual background fields during the poll
settings merge even though the settings page, hooks, migration, and
tests still rely on them. Restore those fields, add poll fields to the
documentation metadata, add the canEditVirtualBackground capability,
and update a stale version reference in the service tests.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@judithJn

Copy link
Copy Markdown
Contributor Author

Ma approve workflow

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project.

@RUKAYAT-CODER
RUKAYAT-CODER merged commit 268031c into rinafcode:main Aug 28, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants