added versioning
This commit is contained in:
1 parent
5b2da87f05
commit
c82b112624
8 files changed
+3888
-107
No files matched your search
@@ -0,0 +1,31 @@
|
||||
/// <reference lib="webworker" />
|
||||
declare const self: ServiceWorkerGlobalScope;
|
||||
|
||||
import { clientsClaim } from 'workbox-core';
|
||||
import { cleanupOutdatedCaches, precacheAndRoute } from 'workbox-precaching';
|
||||
|
||||
// Bump this version to force SW update - changes to this constant change the SW file hash
|
||||
const CACHE_VERSION = '2026-03-06-v1';
|
||||
|
||||
// @ts-ignore - __WB_MANIFEST is injected at build time by vite-plugin-pwa
|
||||
precacheAndRoute(self.__WB_MANIFEST);
|
||||
|
||||
cleanupOutdatedCaches();
|
||||
|
||||
// Force immediate activation of new SW
|
||||
self.addEventListener('install', () => {
|
||||
console.log('[SW] Installing, skipping waiting...');
|
||||
self.skipWaiting();
|
||||
});
|
||||
|
||||
self.addEventListener('activate', () => {
|
||||
console.log('[SW] Activating, claiming clients...');
|
||||
clientsClaim();
|
||||
});
|
||||
|
||||
// Handle SKIP_WAITING message from client
|
||||
self.addEventListener('message', (event) => {
|
||||
if (event.data?.type === 'SKIP_WAITING') {
|
||||
self.skipWaiting();
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user