I'm trying to debug a site on my iPhone4 (iOS4) iPad1 (iOS3.3) and desktop.
My problem is I cannot clear the iPhone cache at all.
If I add alerts/consoles to the js files I'm debugging, they show up on iPad and desktop, but the iPhone just keeps reloading from the cache.
If I clear the cache through settings>safari>delete browser history, cache, cookies
and in Safari delete all bookmarks and remove the files on the server, iPad and desktop break (missing files) but the iPhone still loads the page as if nothing happened.
Not sure this is the right place to ask, but maybe someone else has a similar experience and an idea how to workaround?
Thanks!
EDIT:
I played around with this some more. If I start an appliction through the icon the cache seems cleared. Only when I open the page in Mobile Safari, it still uses the wrong file from cache. Pointers still welcome!
EDIT:
I'm starting a bounty on this. I'm using RequireJS and JqueryMobile on the site, so these may also be reasons for the cache not clearing. Still, I don't understand why it clears in app-mode and why it doesn't clear in Mobile Safari.
I have tried the following:
1. Clicking reload page
in the URL bar does not clear the cache. Clicking on the link and then loading the page via go
does seem to clear the cache once in a while
Even though this is a bit hacky, maybe have a go at this workaround (I'm assuming this is for development)
As per the notes in disabling ajax cacheing here How to disable Ajax caching in Safari browser? you could set no-cache headers while developing or in plain HTML like this
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
obviously it won't fix your initial issue of being stuck. but you can break the cycle by adding an arbitrary query parameter ?something=3164 so the URL is effectively unique. then next time it loads hopefully it will hold onto the no-cache params.
If even that then doesnt work you could set up a bookmark which redirected you to a different random=14361 number each time to they are all effectively unique calls - but then we're getting into silly territory!
I'd like to have a proper solution but when I'm developing JS webapps I've found that sometimes everything refreshes properly for a while, then sometimes it doesnt... no real pattern i can tell - apart from the fact i think it seems to do it less when the debugger is enabled (but thats totally unsubstantiated ;-)
When developing for iOS mobile, you can clear the cache easily by plugging the phone to a computer via USB and using the developing tools:
- In the phone, enable developing tools: Settings/Safari/Advanced
- In the computer, enable Safari develop menu: Settings/Advanced
- Make sure the mobile Safari is open and inspect the phone: Develop/PHONE_NAME/TAB_NAME
- Now you press cmd-shift-r to clear the cache in phone
Try stopping safari and restart it and delete all the pages that are there in safari.... see the image how to close the pages
Are you dealing with an HTML5 "offline" application? The use of a manifest file for offline apps is quite new, and has strange quirks for each browser. Modify the manifest file on the server, and the iPhone should fetch the pages again.
EDIT:
If you ever had a manifest file (and the HTML attribute pointing to it), if you remove the manifest in the wrong order, your cache can get tangled:
- HTML and manifest exist
- Remove the manifest file, and reload the HTML page => HTML page should un-manifest, since manifest 404's, but on some browsers it doesn't.
- Modify the HTML => HTML page doesn't un-cache, since the (non-existant) manifest file hasn't changed.
To correctly un-manifest it, try:
- Add the HTML and manifest back in
- Remove the HTML manifest attribute first, and reload the page
- Then remove the manifest file from the server.
there is another solution with out restarting your device for safari,
- Go to
Settings
- Then go down and go to
Safari
Then go down and see options Clear Cookie and Data
as in below Image
Now go back to your safari and you are done!
if you have any more question comment below.
What works for me is searching my site on Google and click on the Google search result.