Broadcast updates to pages with service workers

Andrew Guan
Andrew Guan
Demián Renzulli
Demián Renzulli

In some scenarios the service worker might need to proactively communicate with any of the active tabs it controls to inform of a certain event. Examples include:

  • Informing the page when a new version of the service worker has been installed, so that the page can show an "Update to refresh" button to the user to access the new functionality immediately.
  • Letting the user know about a change on cached data that took place on the service worker side, by showing an indication, like: "The app is now ready to work offline", or "New version of the content available".
Diagram showing a service worker communicating with the page to send an update.