fix: bust service worker cache on each build with version+timestamp

The SW cache name was hardcoded to 'pinchchat-v1', meaning PWA users
would get stale cached assets forever. Now the cache name includes
the package version and build timestamp, so each build creates a new
cache and old ones are cleaned up on activation.

Also adds:
- Periodic SW update check (every 30 min)
- Auto-reload when new SW version is detected
This commit is contained in:
Nicolas Varrot
2026-02-13 11:57:32 +00:00
parent 13f5c4ac0c
commit 72e9bce4c5
3 changed files with 41 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
// PinchChat Service Worker — cache static assets for offline/instant load
const CACHE_NAME = 'pinchchat-v1';
const CACHE_NAME = 'pinchchat-__SW_VERSION__';
// Cache static assets on install
self.addEventListener('install', (event) => {