On iOS, where is the “add to homepage” cache kept,

2019-06-07 06:11发布

问题:

I'm making an html5 game on the iPad (iOS v7) and it's very stubborn about releasing the cache when I add it to the homepage. This works the way you'd expect if I view it in Safari: If I refresh once or twice, the page gets cached in its latest state.

But on the homepage it's a different story. It keeps on using the old cache instead of the latest. I've noticed that if I clear Safari's data in the settings, I can force Safari to refresh the cache the next time I view the site. But, if I delete the Safari data, I can still view the old app in the icon that's on my homepage. So how do I clear the data the the "Add to Homepage" version is using?


This might be the same (unanswered) question, but it's asking about iOS 6, not 7. So, it may be different.

回答1:

This is a massive pain, but this can be fixed by changing the name of the manifest file every time you want to use a newer version.

It's important that the old file no longer exists on the server. If the app can grab the old one off the server, it'll use that instead of the new one even if the new html file refers to the new one.



回答2:

Well, I tried quite a few things but I was able to clear caches in iOS 7 by going into the phone's Settings -> Safari -> Advanced and turning off Javascript, loading the page without Javascript, then turning it back on. It also cleared the Add To Home Screen cache finally.

This works for Javascript files. Mobile Safari seems to have a bug where a Javascript file which had a syntax error becomes wedged in the cache forever. Especially if you attach a debugger. Chrome had a similar problem in the past, but in the new versions it's solved by opening a new tab.