2025-11-13 20:42:43 +01:00
|
|
|
const CACHE_NAME = 'mywebdav-cache-v11';
|
2025-11-09 23:29:07 +01:00
|
|
|
const urlsToCache = [
|
|
|
|
|
'/',
|
|
|
|
|
'/static/index.html',
|
|
|
|
|
'/static/css/style.css',
|
|
|
|
|
'/static/js/main.js',
|
2025-11-13 20:42:43 +01:00
|
|
|
'/static/js/components/mywebdav-app.js',
|
2025-11-09 23:29:07 +01:00
|
|
|
'/static/manifest.json',
|
|
|
|
|
'/static/icons/icon-192x192.png',
|
|
|
|
|
'/static/icons/icon-512x512.png'
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
self.addEventListener('install', event => {
|
|
|
|
|
event.waitUntil(
|
|
|
|
|
caches.open(CACHE_NAME)
|
|
|
|
|
.then(cache => {
|
|
|
|
|
return cache.addAll(urlsToCache);
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
self.addEventListener('fetch', event => {
|
|
|
|
|
event.respondWith(
|
|
|
|
|
caches.match(event.request)
|
|
|
|
|
.then(response => {
|
|
|
|
|
if (response) {
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
return fetch(event.request);
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
self.addEventListener('activate', event => {
|
|
|
|
|
event.waitUntil(
|
|
|
|
|
caches.keys().then(cacheNames => {
|
|
|
|
|
return Promise.all(
|
|
|
|
|
cacheNames.map(cacheName => {
|
|
|
|
|
if (cacheName !== CACHE_NAME) {
|
|
|
|
|
return caches.delete(cacheName);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
});
|