mirror of
https://github.com/KuekHaoYang/KVideo.git
synced 2026-08-12 23:33:43 +08:00
18 lines
534 B
JavaScript
18 lines
534 B
JavaScript
const LEGACY_CACHE_PREFIXES = ['video-cache-'];
|
|
|
|
self.addEventListener('install', () => {
|
|
self.skipWaiting();
|
|
});
|
|
|
|
self.addEventListener('activate', (event) => {
|
|
event.waitUntil(
|
|
caches.keys()
|
|
.then((cacheNames) => Promise.all(
|
|
cacheNames
|
|
.filter((cacheName) => LEGACY_CACHE_PREFIXES.some((prefix) => cacheName.startsWith(prefix)))
|
|
.map((cacheName) => caches.delete(cacheName))
|
|
))
|
|
.then(() => self.clients.claim())
|
|
);
|
|
});
|