You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

serviceworker.js 622B

1234567891011121314151617181920212223
  1. import {registerRoute} from 'workbox-routing';
  2. import {StaleWhileRevalidate} from 'workbox-strategies';
  3. const cacheName = 'static-cache-v2';
  4. // disable workbox debug logging in development, remove when debugging the service worker
  5. self.__WB_DISABLE_DEV_LOGS = true;
  6. // see https://developer.mozilla.org/en-US/docs/Web/API/RequestDestination for possible values
  7. const cachedDestinations = new Set([
  8. 'font',
  9. 'manifest',
  10. 'paintworklet',
  11. 'script',
  12. 'sharedworker',
  13. 'style',
  14. 'worker',
  15. ]);
  16. registerRoute(
  17. ({request}) => cachedDestinations.has(request.destination),
  18. new StaleWhileRevalidate({cacheName}),
  19. );