Actually upload the PWA files
This commit is contained in:
33
sw.js
Normal file
33
sw.js
Normal file
@ -0,0 +1,33 @@
|
||||
const CACHE_NAME = 'v1';
|
||||
const ASSETS = [
|
||||
'/',
|
||||
'/index.html',
|
||||
'/script.js',
|
||||
'/styles.css',
|
||||
'/manifest.json',
|
||||
'/icons/192.svg',
|
||||
'/icons/512.svg',
|
||||
'/vendor/lucio/graham-scan.mjs'
|
||||
];
|
||||
|
||||
self.addEventListener('install', (e) => {
|
||||
e.waitUntil(
|
||||
caches.open(CACHE_NAME).then(cache => cache.addAll(ASSETS))
|
||||
);
|
||||
self.skipWaiting();
|
||||
});
|
||||
|
||||
self.addEventListener('activate', (e) => {
|
||||
e.waitUntil(
|
||||
caches.keys().then(keys =>
|
||||
Promise.all(keys.filter(k => k !== CACHE_NAME).map(k => caches.delete(k)))
|
||||
)
|
||||
);
|
||||
self.clients.claim();
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', (e) => {
|
||||
e.respondWith(
|
||||
caches.match(e.request).then(response => response || fetch(e.request))
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user