nuxt-community / pwa-module

Zero config PWA solution for Nuxt.js
https://pwa.nuxtjs.org
MIT License
1.23k stars 171 forks source link

Nuxt app does not update after removing @nuxt/pwa #461

Open TaeyoonKwon opened 3 years ago

TaeyoonKwon commented 3 years ago

I have removed npm package by npm remove @nuxt/pwa and all the configs from nuxt.config.js file.

However, it seems the site does not update and is still pwa unless I completely remove cache from the browser.

Is there anyway I can force update the app?

JohnMica commented 2 years ago

perhaps you could add something like this to you default.vue layout ? I know it did work for me.

// remove service worker and deregister it, delete cache on all browsers
    // if (window.navigator && navigator.serviceWorker) {
    //   navigator.serviceWorker.getRegistrations().then(function (registrations) {
    //     for (const registration of registrations) {
    //       registration.unregister()
    //     }
    //   })
    // }
    // if ('caches' in window) {
    //   caches.keys().then(function (keyList) {
    //     return Promise.all(
    //       keyList.map(function (key) {
    //         return caches.delete(key)
    //       })
    //     )
    //   })
    // }
    // if ('serviceWorker' in navigator) {
    //   navigator.serviceWorker.getRegistrations().then(function (registrations) {
    //     for (const registration of registrations) {
    //       // unregister service worker
    //       console.log('serviceWorker unregistered')
    //       registration.unregister()
    //       setTimeout(function () {
    //         console.log('trying redirect do')
    //         window.location.replace(window.location.href) // because without redirecting, first time on page load: still service worker will be available
    //       }, 3000)
    //     }
    //   })
    // }