DEV Community

Discussion on: Handling Service Worker updates in your Vue PWA

Collapse
 
dharmendradavid profile image
dharmendradavid

Thank you for this wonderful article. This is working fine if we refresh the page and showing an update prompt. But this not working without a refreshing page. Especially in the case of SPA. Please help me to show update prompt without refresh page

Collapse
 
ajlozier profile image
Aaron Lozier

I had the same question. Turns out you can create an interval to poll for updates in registerServiceWorker.js:

 registered(registration) {
      console.log(
        'Service worker has been registered and now polling for updates.'
      )
      setInterval(() => {
        registration.update()
      }, 5000) // every 5 seconds
    }
Enter fullscreen mode Exit fullscreen mode
Collapse
 
frynt profile image
frynt

This works perfectly ! thanks !