tweak service worker
This commit is contained in:
parent
1f842a09dd
commit
ecc3d02167
|
|
@ -1,5 +1,9 @@
|
||||||
import { registerRoute } from 'workbox-routing'
|
import { registerRoute } from 'workbox-routing'
|
||||||
import { CacheFirst, StaleWhileRevalidate } from 'workbox-strategies'
|
import {
|
||||||
|
CacheFirst,
|
||||||
|
StaleWhileRevalidate,
|
||||||
|
NetworkOnly,
|
||||||
|
} from 'workbox-strategies'
|
||||||
import { ExpirationPlugin } from 'workbox-expiration'
|
import { ExpirationPlugin } from 'workbox-expiration'
|
||||||
|
|
||||||
registerRoute(
|
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(
|
registerRoute(
|
||||||
({ request }) => request.destination === 'script',
|
({ request }) => request.destination === 'script',
|
||||||
new StaleWhileRevalidate({
|
new StaleWhileRevalidate({
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<script>
|
<script>
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
navigator.serviceWorker.register('/sw.js?v3')
|
navigator.serviceWorker.register('/sw.js?v4')
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
{% for link in links %}
|
{% for link in links %}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user