title: service worker update while app is in background
body: <p>We're using workbox. We programmatically refresh the page if the user opens the installed PWA and there's a new version available.</p>
  
  <p>It would be a better user experience if we do that while the app is in the background on user's device.</p>
  
  <p>I haven't found any reference to that on google and SO.</p>
  
  <p>Are there any examples of this? If I will make one, would anyone find it useful?</p>
  
  <p>I'm spuprised it's not the de facto approach these days, but maybe there's something I'm missing here ...</p>
  
  <p>I'm thinking of the following approach:</p>
  
  <ol>
  <li><p>Service worker is polling from server to check if a new version is available (or connects through WebSocket)</p></li>
  <li><p>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.</p></li>
  </ol>
  
  <p>I would appreciate any thoughts and pointers on this, and if someone knows of a better approach for this.</p>