Reduce service worker caching to avoid stale bundles
This commit is contained in:
parent
9ae743364a
commit
ae61e19e09
|
|
@ -1,8 +1,6 @@
|
||||||
// public/service-worker.js
|
// public/service-worker.js
|
||||||
const CACHE_NAME = 'sociowire-v3';
|
const CACHE_NAME = 'sociowire-v4';
|
||||||
const PRECACHE = [
|
const PRECACHE = [
|
||||||
'/',
|
|
||||||
'/index.html',
|
|
||||||
'/icons/icon-192x192.png',
|
'/icons/icon-192x192.png',
|
||||||
'/icons/icon-512x512.png',
|
'/icons/icon-512x512.png',
|
||||||
'/icons/apple-touch-icon.png',
|
'/icons/apple-touch-icon.png',
|
||||||
|
|
@ -36,12 +34,7 @@ self.addEventListener('fetch', event => {
|
||||||
if (event.request.mode === 'navigate') {
|
if (event.request.mode === 'navigate') {
|
||||||
event.respondWith(
|
event.respondWith(
|
||||||
fetch(event.request)
|
fetch(event.request)
|
||||||
.then(response => {
|
.catch(() => caches.match('/'))
|
||||||
const copy = response.clone();
|
|
||||||
caches.open(CACHE_NAME).then(cache => cache.put('/index.html', copy));
|
|
||||||
return response;
|
|
||||||
})
|
|
||||||
.catch(() => caches.match('/index.html'))
|
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue