tweak service worker
This commit is contained in:
parent
1f842a09dd
commit
ecc3d02167
@ -1,5 +1,9 @@
|
||||
import { registerRoute } from 'workbox-routing'
|
||||
import { CacheFirst, StaleWhileRevalidate } from 'workbox-strategies'
|
||||
import {
|
||||
CacheFirst,
|
||||
StaleWhileRevalidate,
|
||||
NetworkOnly,
|
||||
} from 'workbox-strategies'
|
||||
import { ExpirationPlugin } from 'workbox-expiration'
|
||||
|
||||
registerRoute(
|
||||
@ -33,6 +37,18 @@ registerRoute(
|
||||
}),
|
||||
)
|
||||
|
||||
registerRoute(/.+\/\d+\.js$/, new NetworkOnly())
|
||||
|
||||
registerRoute(
|
||||
/\/app\/\w{2,3}\.\w{7}\.js$/,
|
||||
new CacheFirst({
|
||||
cacheName: 'javascript-v1',
|
||||
fetchOptions: {
|
||||
credentials: 'omit',
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
registerRoute(
|
||||
({ request }) => request.destination === 'script',
|
||||
new StaleWhileRevalidate({
|
||||
|
@ -12,7 +12,7 @@
|
||||
{% endif %}
|
||||
<script>
|
||||
window.addEventListener('load', () => {
|
||||
navigator.serviceWorker.register('/sw.js?v3')
|
||||
navigator.serviceWorker.register('/sw.js?v4')
|
||||
})
|
||||
</script>
|
||||
{% for link in links %}
|
||||
|
Loading…
Reference in New Issue
Block a user