koel/sw.js

20 lines
483 B
JavaScript
Raw Normal View History

2019-03-13 07:21:56 +00:00
importScripts('https://storage.googleapis.com/workbox-cdn/releases/4.0.0/workbox-sw.js')
workbox.routing.registerRoute(
new RegExp('.*\.js'),
new workbox.strategies.NetworkFirst()
)
workbox.routing.registerRoute(
/\.(?:png|jpg|jpeg|svg|gif|eot|ttf|woff2?|otf)$/,
new workbox.strategies.CacheFirst({
cacheName: 'image-font-cache',
plugins: [
new workbox.expiration.Plugin({
maxEntries: 20,
maxAgeSeconds: 7 * 24 * 60 * 60
})
]
})
)