Files
hertzbeat/home/src/sw.js

18 lines
573 B
JavaScript
Raw Normal View History

2022-02-02 22:49:50 +08:00
import { registerRoute } from 'workbox-routing'
import { StaleWhileRevalidate } from 'workbox-strategies'
export default function swCustom(params) {
if (params.debug) {
console.log('[WebdriverIO-PWA][SW]: running swCustom code', params)
}
// Cache responses from external resources
registerRoute((context) => {
return [
/graph\.facebook\.com\/.*\/picture/,
/netlify\.com\/img/,
/avatars1\.githubusercontent/,
].some((regex) => context.url.href.match(regex))
}, new StaleWhileRevalidate())
}