sw.js 573 B

1234567891011121314151617
  1. import { registerRoute } from 'workbox-routing'
  2. import { StaleWhileRevalidate } from 'workbox-strategies'
  3. export default function swCustom(params) {
  4. if (params.debug) {
  5. console.log('[WebdriverIO-PWA][SW]: running swCustom code', params)
  6. }
  7. // Cache responses from external resources
  8. registerRoute((context) => {
  9. return [
  10. /graph\.facebook\.com\/.*\/picture/,
  11. /netlify\.com\/img/,
  12. /avatars1\.githubusercontent/,
  13. ].some((regex) => context.url.href.match(regex))
  14. }, new StaleWhileRevalidate())
  15. }