GoogleChromeLabs / sw-precache

[Deprecated] A node module to generate service worker code that will precache specific resources so they work offline.
https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-sw
Apache License 2.0
5.22k stars 388 forks source link

Cache Fetch fails on iOS #371

Open crb04c opened 6 years ago

crb04c commented 6 years ago

The v3 of the tool doesn't seem to work properly on iOS. The cache load throws an exception and ends up always performing a network fetch. This breaks the ability to have an offline app.

Note: Using a simple service worker (one that doesn't do the redirect clean up/etc) does work properly.

Edit: It looks like setting the cache name to a shorter simple string seems to fix it as well.

var precacheConfig = <%= precacheConfig %>; var cacheName = 'simple';

bobbylej commented 6 years ago

Looks like I have a similar issue, but @crb04c fix is working only temporary for me, i.e. on iPhone 8 plus (iOS 12) after hour app cannot be loaded in offline mode again, but on a second device, it's working for a long time. Maybe changing the name just updates data in cache and safari is removing some them again after some time, I don't know, just wild guess.

Edit: This bug is more related to this issue Bug 190269 - IOS 12 - Service worker cache not shared when added to homescreen