13 lines
361 B
JavaScript
13 lines
361 B
JavaScript
const CACHE = 'safeaccess-v1';
|
|
const ASSETS = ['/', '/index.html', '/manifest.json'];
|
|
|
|
self.addEventListener('install', e => {
|
|
e.waitUntil(caches.open(CACHE).then(c => c.addAll(ASSETS)));
|
|
});
|
|
|
|
self.addEventListener('fetch', e => {
|
|
e.respondWith(
|
|
caches.match(e.request).then(r => r || fetch(e.request)).catch(() => caches.match('/index.html'))
|
|
);
|
|
});
|