We're using workbox. We programmatically refresh the page if the user opens the installed PWA and there's a new version available.

It would be a better user experience if we do that while the app is in the background on user's device.

I haven't found any reference to that on google and SO.

Are there any examples of this? If I will make one, would anyone find it useful?

I'm spuprised it's not the de facto approach these days, but maybe there's something I'm missing here ...

I'm thinking of the following approach:

1. Service worker is polling from server to check if a new version is available (or connects through WebSocket)
2. If new version is found, service worker checks if the app is active/in the foreground. If it is, notify user about the new version, and offer a refresh for updates. If not, programtically make the reload, and restore the state of the app on load.

I would appreciate any thoughts and pointers on this, and if someone knows of a better approach for this.