问题
iOS 12 Safari does not support the offline feature of some PWAs (Progressive Web App). It seems like Safari does not cache resources in those web apps properly.
For example, the following PWAs cannot work offline in iOS 12 and 12.1, but they all work perfectly in Chrome on Android or Windows:
The Air Horner PWA that is used by google to demonstrate Service Worker:
Air Horner
And these two:
2048 puzzle
Voice Memos
Steps to reproduce (100% reproducible):
- visit the PWA with Safari (iOS 12 or 12.1)
- close the PWA tab in Safari
- push home button on iPhone to set Safari to background
- push the iPhone power button to turn off screen
- push the iPhone power button again to wake up the phone
- turn off all the network connection from the iPhone control center (both wifi and cellular)
- open Safari, visit PWA again --> the web app fail to load
This has been bothering me for a long time, as my own web app also has the similar issue - works fine in Chrome on Android / Windows but only fails on iOS 12 Safari. Any idea what special in iOS 12 Safari? Thank you very much!
回答1:
I had the same issue, using service worker without Workbox resolved the problem - app starts without internet connection but something is messed up with caching - it's not working.
回答2:
I faced the exact same issues.
What I realized is, all the caches are set correctly when the service worker is activated, but if you close safari with the iOS task manager (not only reduce it), all cached files get completely deleted when going back on the PWA.
回答3:
Indeed offline works in the Homescreen. However, the cache does not get updated on new versions & the Homescreen link stops working. To refresh the cache, one is obliged to access the web app from Safari, and then it works again. This is really sub-optimal & will hopefully be fixed.
回答4:
The issue is resolved in iOS 12.1.2 on my iPhone 6S.
来源:https://stackoverflow.com/questions/53439379/ios-12-does-not-support-offline-feature-of-some-pwas