NekR / offline-plugin

Offline plugin (ServiceWorker, AppCache) for webpack (https://webpack.js.org/)
MIT License
4.52k stars 294 forks source link

Multiple tabs scenario #473

Open pratikt-cuelogic opened 4 years ago

pratikt-cuelogic commented 4 years ago

We are planning to show modal informing user that

There's new version of this website available, please reload your browser to see the latest version.

my configuration is

new OfflinePlugin({
        excludes: ['**/.*', '**/*.map', '**/*.jpg', '**/*.png', '**/*.gz', '**/google-fonts.*', '**/**/google-fonts.*'],
        updateStrategy: 'changed',
        responseStrategy: 'network-first', // default: cache-first
        autoUpdate: 1000 * 60 * 5, //check every 5 minute
        ServiceWorker: {
          events: true,
          navigateFallbackURL: '/',
        },
      }),

Seems it is working fine for normal usecase, however users can have multiple tabs open (for our application its most likely), based on this configuration it will display modal for tabs asking user to refresh. However

as per service worker's working - User need to close all tabs or fully close the browser to see the changes reflected. A page reload will not reflect the changes.

will it work by just refreshing all tabs? any better user experience we can have ? as service worker is shared across multiple tabs, how can we utilise it better ?