I've run into a problem where I add a web app to my iPad home screen (iOS 5.0.1 iPad 2), and when I open it it appears to be caching something behind the scenes, independent of Safari.
I've cleared out everything from Safari that's available in Settings (Clear History and Clear Cookies & Data), and when I navigate to the web app with Safari I see the app in its current state. However if I open the home screen bookmark I get the app in a pre-changed state.
I've seen a lot of information about using a cache.manifest to cache resources for offline use, but I'm not sure if that's relevant to this since I would like the exact opposite: cache nothing.
I've gone to the level of not even testing external resources; if I change some arbitrary test string in the body element of my index.html, the home screen bookmark does not show the updated text.
Another workaround is to add ?v=1 to your Javascript and CSS links. For example:
It seems one doesn't have to update the number when your file has changed, as far as I can tell. Apparently, on an iPad 2 with the latest software update installed, it is enough to just hint at something dynamic.
Create a
cache.manifest
that instructs it never to cache resources referenced by the main html page:Use it in your
index.html
:Now whenever you change that manifest file -- for example, by increasing the version number in that comment -- the browser will redownload
index.html
also.Ensure your page gets reloaded when the cache is updated:
The Safari Developer Library has good documentation.
You can force the open web app to reload without using the cache if you have the Safari Web Inspector open and pointing at your open web app. With the Web Inspector active, press
SHIFT + COMMAND + R
(on a Mac). You may need to refresh one more time to trigger the updated assets.The latest Safari (v12.0.1) developer tools has a "Ignore resource cache" button at the top right of the Network tab. Check that, then reload.
I've had luck with powering off the device. I had changed the app manifest; but presumably, you need a refresh or something to get the browser to look for it. Since I removed the browser chrome, there's no reset button. We tried "closing" the app (haha) and swiping the app away; but I presume iOS tends to keep things running anyway. Shutting down did the trick to get it to refresh.
Maybe there's some gesture for refresh I don't know. Perhaps one should tuck a little "check for updates" refresh button into cached web apps.
For our iOS webclip apps we are using the following. So far no cache problems:
1- We have one cache manifest file called 'manifest.appcache.php'
2 - In the HTML file we have: