question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

workbox-window method to trigger SW update check

See original GitHub issue

Library Affected: workbox-sw, workbox-window

Browser & Platform: all browsers

Issue or Feature Request Description: If I try to instantiate workbox a second time no events are fired. What I basically want to achieve is that the user presses a button, the service worker should reload and thus he will check for updates. It seems that currently the service worker can only be instantiated once. Appending a random timestamp in the file name causes the service worker to always download everything again.

There should be a method that just checks for updates of the service worker itself.

  const workbox = new Workbox(`/service-worker.js`, {
    scope: '/',
  })
  await workbox.register()

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
daffinmcommented, Nov 2, 2019

It would be really useful, from a UX point of view, if this new update() method could return, somehow, a flag indicating if an update was found or not. If this update check is initiated by the user, for instance by clicking a ‘Check for Updates’ button, this would allow them to be informed that ‘No updates were found’. Otherwise nothing seems to happen…

0reactions
jaulzcommented, Jul 20, 2019

I gave a first try and created a PR which introduces the new update method.

By any chance can you tell me how you usually create examples to reproduce cases like these?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling service worker updates with immediacy
It registers a service worker using workbox-window , and will react if the service worker gets stuck in the waiting phase. When a...
Read more >
Workbox 4: Implementing refresh-to-update-version flow using ...
This method takes care of all the complexity of precaching, version maintaining, fetching updated resources, updating the cache etc. We just ...
Read more >
Inconsistent behaviour with workbox-window.update()
I am using the workbox-window update() method to trigger a service worker update check as described in workbox issue #2130. This question also ......
Read more >
Broadcast updates to pages with service workers - web.dev
The Workbox package workbox-broadcast-update provides a standard way of notifying window clients that a cached response has been updated. This ...
Read more >
11 Service Worker Registration | Workbox Window | React PWA
#11 Service Worker Registration | Workbox Window | Cache update on application re-deploy | React PWA · Key moments. View all · Key...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found