NekR / offline-plugin

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

Infinite reloading on Chrome for iPhone #401

Open matheusml opened 6 years ago

matheusml commented 6 years ago

For some reason, OfflinePlugin is causing an infinite reloading, on the first page of the application, only on Chrome for iPhone.

This is the config:

// index.js
require("offline-plugin/runtime").install();
// webpack.js
new OfflinePlugin({
  externals: ["/"],
  responseStrategy: "network-first"
 })

When I remove the require("offline-plugin/runtime").install(); line, it works just fine.

Again: this is only happening on Chrome on iPhone

matheusml commented 6 years ago

Changing from:

require("offline-plugin/runtime").install();

to:

if ('serviceWorker' in navigator) {
  require("offline-plugin/runtime").install();
}

solved it

GGAlanSmithee commented 6 years ago

@matheusml thanks for updating with the solution, sent a PR to add this to the docs.

NekR commented 6 years ago

install() method as 'serviceWorker' in navigator check inside.

NekR commented 6 years ago

@matheusml which version of iOS and which version of offline-plugin?

matheusml commented 6 years ago

@NekR I'm sorry but I don't have this information anymore :(

GGAlanSmithee commented 6 years ago

@NekR Seems like serivce worker is not implemented on chrome on iOS: https://stackoverflow.com/a/50611655, so there might be an actual issue with the feature detection? Maybe this line?

NekR commented 6 years ago

I'll need to test that. It seems to me like it might be an AppCache issue. Which is disabled by default though in v5..