19 lines
565 B
JavaScript
19 lines
565 B
JavaScript
self.addEventListener('install', event => {
|
|
console.log('Service Worker installing.');
|
|
// Add a call to skipWaiting here if you want the SW to immediately activate
|
|
// self.skipWaiting();
|
|
});
|
|
|
|
self.addEventListener('activate', event => {
|
|
console.log('Service Worker activating.');
|
|
// Take control of all clients immediately
|
|
// event.waitUntil(clients.claim());
|
|
});
|
|
|
|
self.addEventListener('fetch', event => {
|
|
event.respondWith(
|
|
fetch(event.request).catch(() => {
|
|
return new Response('Offline');
|
|
})
|
|
);
|
|
}); |