39 lines
917 B
JavaScript
39 lines
917 B
JavaScript
|
let CACHE_NAME = 'workavdenture-cache-v1';
|
||
|
let urlsToCache = [
|
||
|
'/'
|
||
|
];
|
||
|
|
||
|
self.addEventListener('install', function(event) {
|
||
|
// Perform install steps
|
||
|
event.waitUntil(
|
||
|
caches.open(CACHE_NAME)
|
||
|
.then((cache) => {
|
||
|
return cache.addAll(urlsToCache);
|
||
|
})
|
||
|
);
|
||
|
});
|
||
|
|
||
|
self.addEventListener('fetch', (event) => {
|
||
|
event.respondWith(
|
||
|
caches.match(event.request)
|
||
|
.then((response) => {
|
||
|
return fetch(event.request).then((response) => {
|
||
|
//Dev service worker, just return reponse
|
||
|
return response;
|
||
|
}
|
||
|
);
|
||
|
})
|
||
|
);
|
||
|
});
|
||
|
|
||
|
self.addEventListener('wait', function(event) {
|
||
|
//TODO wait
|
||
|
});
|
||
|
|
||
|
self.addEventListener('update', function(event) {
|
||
|
//TODO update
|
||
|
});
|
||
|
|
||
|
self.addEventListener('beforeinstallprompt', (e) => {
|
||
|
//TODO change prompt
|
||
|
});
|