strange behaviour with cache.manifest / offline usage of web app saved to home-screen on ipad ios6

[亡魂溺海] 提交于 2019-12-20 15:23:42

问题


I just discovered some strange behaviour on iPad with the new iOS 6. I'm testing a web app for offline usage. The web app is no more than a static website with a cache manifest, so no special frameworks like sencha touch or tools like phnoegap are used. Just HTML, CSS and JavaScript and a cache.manifest.

The App worked fine before: I could save the website to the home screen. When I opened it from there, all the data would be downloaded for caching. At the end of the download the pop-up would come to ask if I wanted to increase the cache to 50MB – accepted – everything was fine – offline usage worked.

Now after the update to iOS 6: I made some changes to the app. Deinstalled the app from home-screen. Opened it again in mobile safari. Saved to home screen. When opened the download starts as supposed to. But then it freezes at 99%. When I look it up in the console, I get the error-message: "Application Cache update failed, because size quota was exceeded."

And here comes the weird thing: When I open it in the browser, download starts and at the end I get asked if I want to increase cache size to 50MB. I confirm of course. When I now look in the preferences of safari at "website data", I see that all the cached data for this app is about 33MB!! So not at all more than 50MB!

Is this a bug of iOS6? Did anyone experience any problems with caching data, when saving a website to the home-screen since the update to iOS 6? Thx for any help, as I am really stuck here... Couldn't find anything helpfull on the web...

(Unfortunately I cannot post any link to the web app and/or it's files).

EDIT:

I found some more information on this issue:

http://www.nsbasic.com/blog/?p=928

Apparently wep-apps saved to the home screen are treated now like native apps, meaning each instance of the same web-app saved to the home screen gets it's own "storage sandbox". So the data is independet from the data saved in mobile Safari. This means if you delete all of mobile safari's website-data this has no effect on the web app saved to the home screen (before ios6 they shared the same data).

I also found this:

iOS 6 breaks GeoLocation in webapps (apple-mobile-web-app-capable)

Though not exactly the same topic, it could be related. Apparently web apps saved to the home screen using

<meta content="yes" name="apple-mobile-web-app-capable" />

wont't be able to use geo-location. Geo-location only works when you remove this meta tag from your web app. Maybe this is also a workaround for the caching problem, I couldn't test it yet. But then again: Maybe the cache.manifest is no longer needed if the web apps saved to home screen are treated more like native apps? I will report back here if I find out more.

EDIT2:

Ok after some testing and no useful hints from neither the web nor apple, I found out at least something: When I remove

<meta content="yes" name="apple-mobile-web-app-capable" />

from the site everything of course works fine, because it's just like you open Safari and there I had no problem so far. So my interest is to make it work without the browser chrome. As described above the caching only goes to 99% and then I get the cache size quota exceeding error. Then I just closed the home screen app and opened it again. Now the caching downloads start again and complete just fine! No freezing, no error! And everything seems to be stored localy. I could only test it on the iPad simulator today but I hope I can confirm this as soon as I can get my hands on our device later.

So it seems like instead of being asked if you want to increase the cache size you get the cache size quota exceeding error. Maybe because data storage for home screen apps now is handled differently you don't have to manualy increase the cache size anymore (which of course is pure speculation). Still, if this was the case, there should not be any error. So instead of being asked to increase cache size you have to open the home screen app twice, which is a pretty lame workaround btw...

EDIT3:

I just could confirm this behaviour on a real device: saved to home screen -> opened from home screen -> download to be cached files -> cache size quota exceeding error at the end -> close home screen app (press home button) -> reopen it again -> to be cached files download again -> this time without error -> everthing usable offline.

I also tested it on a device with iOS 5 and there it works like expected without errors. So this is definitely an iOS 6 issue.

Can anyone else confirm this behaviour or bug?

EDIT4:

I occasionally had the chance to test this on iOS 6.1.3 – unfortunately still the same behaviour...


回答1:


I found the following link helpful. It explains that as Home Screen apps are now stored like native apps, they have their own storage/caching.

Geolocation works on the first iteration but fails to update from then on.

iOS 6 Geolocation and Local Data Storage

"Data in Home Screen apps are now stored like native apps. Native apps each have their own sandbox where their data is stored, backed up and restored to. Prior to iOS 6, Home Screen apps shared data with the same app running in the browser. If the user cleared the cache in the browser, the Home Screen version of the app would lose its data too.With iOS 6, Home Screen apps’ data gets saved to a sandbox just like native apps. Backups and restores handle the data properly, and clear cache in the browser will not affect them."



来源:https://stackoverflow.com/questions/12625297/strange-behaviour-with-cache-manifest-offline-usage-of-web-app-saved-to-home-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!