Browse Source

Skip waiting, update service worker

file-group-page
bat 3 years ago
parent
commit
5d3026ae6b
  1. 5
      app.js
  2. 1
      sw.js

5
app.js

@ -12,8 +12,9 @@ customElements.define('m-page-menu', PageMenu)
class Setup { class Setup {
async run() { async run() {
navigator.serviceWorker const sw = navigator.serviceWorker
.addEventListener('controllerchange', () => {
sw.addEventListener('controllerchange', () => {
if (this.registration.active) { if (this.registration.active) {
window.location.reload(true) window.location.reload(true)
} }

1
sw.js

@ -13,6 +13,7 @@ async function initCache() {
} }
self.addEventListener("install", event => { self.addEventListener("install", event => {
self.skipWaiting()
event.waitUntil(initCache()) event.waitUntil(initCache())
}) })

Loading…
Cancel
Save