Why my Mobile Safari cache won't clear?

2019-03-11 01:13发布

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

6条回答
神经病院院长
2楼-- · 2019-03-11 01:25

there is another solution with out restarting your device for safari,

  1. Go to Settings
  2. Then go down and go to Safari
  3. Then go down and see options Clear Cookie and Data as in below ImageiPhone Safari Clear Cookie and Data

  4. Now go back to your safari and you are done!

if you have any more question comment below.

查看更多
forever°为你锁心
3楼-- · 2019-03-11 01:27

Try stopping safari and restart it and delete all the pages that are there in safari.... see the image how to close the pages enter image description here

查看更多
时光不老,我们不散
4楼-- · 2019-03-11 01:33

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 ;-)

查看更多
老娘就宠你
5楼-- · 2019-03-11 01:41

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:

  1. In the phone, enable developing tools: Settings/Safari/Advanced
  2. In the computer, enable Safari develop menu: Settings/Advanced
  3. Make sure the mobile Safari is open and inspect the phone: Develop/PHONE_NAME/TAB_NAME
  4. Now you press cmd-shift-r to clear the cache in phone
查看更多
Anthone
6楼-- · 2019-03-11 01:41

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:

  1. HTML and manifest exist
  2. 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.
  3. Modify the HTML => HTML page doesn't un-cache, since the (non-existant) manifest file hasn't changed.

To correctly un-manifest it, try:

  1. Add the HTML and manifest back in
  2. Remove the HTML manifest attribute first, and reload the page
  3. Then remove the manifest file from the server.
查看更多
孤傲高冷的网名
7楼-- · 2019-03-11 01:47

What works for me is searching my site on Google and click on the Google search result.

查看更多
登录 后发表回答