sw.js 597 B

1234567891011121314151617181920
  1. // This is the "Offline copy of pages" service worker
  2. // eslint-disable-next-line no-restricted-globals
  3. self.addEventListener('install', event => {
  4. const offlinePage = new Request('/offline');
  5. event.waitUntil(
  6. fetch(offlinePage).then(response =>
  7. caches.open('kutt-offline-v1').then(cache => cache.put(offlinePage, response))
  8. )
  9. );
  10. });
  11. // eslint-disable-next-line no-restricted-globals
  12. self.addEventListener('fetch', event => {
  13. event.respondWith(
  14. fetch(event.request).catch(() =>
  15. caches.open('kutt-offline-v1').then(cache => cache.match('/offline'))
  16. )
  17. );
  18. });