21 lines
485 B
JavaScript
21 lines
485 B
JavaScript
self.addEventListener('install', (event) => {
|
|
event.waitUntil(
|
|
caches.open('pwa-cache-v1').then((cache) => {
|
|
return cache.addAll([
|
|
'/',
|
|
'/index.html',
|
|
'/styles/style.css',
|
|
'/icons/icon-192x192.png',
|
|
'/icons/icon-512x512.png'
|
|
]);
|
|
})
|
|
);
|
|
});
|
|
|
|
self.addEventListener('fetch', (event) => {
|
|
event.respondWith(
|
|
caches.match(event.request).then((response) => {
|
|
return response || fetch(event.request);
|
|
})
|
|
);
|
|
});
|