It would appear that Apple have changed the way homescreen/standalone web apps work in iOS 6. According to various blog posts (example) these apps now get their own dedicated space for storing their cached files, sqllite dbs, local storage etc, rather than sharing with the Safari browser like before.
Before iOS 6 when developing I used to go through the following procedure religiously to clear the cache...
- Remove app from homescreen.
- Close all pages/tabs in Safari.
- Finally "Clear Cookies & Data" or "Clear Data" in "Settings" > "Safari".
Unfortunately now that Apple have moved the goal posts this same procedure doesn't seem to work. After clearing, even though my changes are picked up in Safari, when I add to the homescreen and launch the app the old HTML,JS etc is still picked up.
Does anyone know how to reliably fully clear the cache in iOS 6?
I can't verify the cache being cleared properly but this worked for me :
In order to do this, you need to allow Web Inspector on your iOS device. Go to Settings > Safari > Advanced > Web Inspector (it has to be active) And you have to activate the developer menu on your computer's Safari. Go to Preferences > Advanced > Activate Developer menu
Somehow the Webapp cache got cleared and i got the non-cached code.
This drove me nuts for a while. Tried clearing the cache on device - no luck. Renaming the page did help, but once you rename it back, you still get the same stale version. Found the solution yesterday. You need to connect your device to Mac and open Web Inspector in Safari Develop menu. Once in Web Inspector, simply press "Reload page" button on the Inspector's toolbar and - voila - you see the fresh version on your device's screen.
Just set the request you pass to the webview to NSURLRequestReloadIgnoringLocalCacheData
Try appending a unique GET tag to the ends of any and all href attributes, for example:
This would generate
href="/css/global.css?########"
, with a different number nearly every time. This forces iOS' Safari to pull the "new" page down, as there is no data in its cache originating from the same URI, and there likely never will be (unless you plan on reloading the app millions of times during development :D )If the iOS6 device has a jailbreak applied, you can use ssh to delete the content of the folder "/private/var/mobile/Library/Caches/com.apple.webapp".
Next time that you start the web app, all files will be re-downloaded from the webserver.
You can connect your device and open Safari's web inspector on your computer and run
document.location.reload()
in the console tab to reload the page.Before reloading you can press Option+Command+E to make sure the cache is cleared.
Instead of above you can also press Shift+Command+R to reload the page without cache but sometimes it hasn't worked for me.