NekR / offline-plugin

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

Using "network-first" does not update cache when network is not offline #417

Closed art0rz closed 5 years ago

art0rz commented 6 years ago

The app cache is not updated when using "network-first" responseStrategy and refreshing the app. Steps to reproduce:

  1. Use OfflinePlugin with responseStrategy set to "network-first"
  2. Add console.log('1') to your app
  3. Run app in browser, have SW install the cache, notice 1 being logged in your browser console
  4. Disable network and refresh, notice site is served from cache and 1 being logged
  5. Reenable network. Change the console.log call to console.log('2')
  6. Refresh app, notice 2 being logged. Cache should be updated
  7. Disable your network, refresh app, notice 1 being logged in your console
andybflynn commented 5 years ago

Might be a bit late to the party here but I think there is a step between 6 and 7 that you're missing. Please bear in mind I haven't tried to reproduce the issue using your steps, so I apologise if you've already tried the below and are still encountering the problem.

The old service worker will not be de-registered and the new one will not be installed until the browser tabs have been closed, so after step 6, having refreshed the page and pulled down the new service worker, the next step should be Close all tabs associated with the application and then reopen the application before disabling the network to check the cache.

GGAlanSmithee commented 5 years ago

@art0rz please follow the steps outlined in https://github.com/NekR/offline-plugin/blob/master/docs/updates.md if the problem persists, please re-open this issue.