partey_workadventure/front/dist/service-worker-dev.js
grégoire parant 22a46a98ea
Improve service worker (#1353)
* Improve service worker

 - Add new env variable in WebPack "NODE_ENV"
 - Add new service worker for mode dev that permit to by pass response in cache storage
 - Add new WorkAdventure icon

* Remove console.log

* Add service worker file prod and dev
2021-08-10 22:34:46 +02:00

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
});