How to disable cache on IOS safari?

43,814

Solution 1

I just stumbled across a way to disable cache in Safari on iOS:

iOS

  1. Open Settings
  2. Navigate to Safari > Advanced
  3. Enable Web Inspector
  4. Switch back to Safari and load a web page

Desktop

  1. Open Safari
  2. Navigate to Safari > Preferences > Advanced tab
  3. Enable the Develop menu
  4. In the Develop menu, select Your iOS Device Name > The Page You Want to Debug
  5. Press Command-Shift-R to reload while disabling cache
  6. Bonus: This is a full Web Inspector on your computer inspecting a page on your iOS device

If you want something more permanent, you'll either have to go the proxy route or make a UIWebView/WKWebView wrapper app that disables caching.

Solution 2

I could be wrong, but on iOS does putting Safari in Private Browsing mode disable cache?

Solution 3

There is a way to effectively disable caching on iphone/ipad/IOS.

Install Fiddler on a windows desktop, and allow remote computers to connect:

enter image description here

In IOS, setup a proxy under your wifi connection settings, pointing to to the IP address of the computer you are running fiddler on, and on port 8888 (assuming you haven't changed it from default in fiddler):

enter image description here

By now, fiddler should be intercepting all web requests your device is making.

You can now disable caching from the Rules -> Performance menu in fiddler.

enter image description here

Solution 4

Doesn't seems like possible. On desktop safari, there is a option to disable cache in developer tools, however there isn't one on mobile safari. I didn't find the option in other browsers like opera neither.

If you wanna try, you can overwrite a desktop firefox's user agent string and make it a fake ipad mobile browser, and then disable cache. But that will depends on what you want to test and it could not work at all.

Hope this helps.

Share:
43,814
Dean
Author by

Dean

Updated on September 26, 2020

Comments

  • Dean
    Dean over 3 years

    Is there a way to disable caching on ipad/iphone? I want to run some automated tests for non-cache experience.

  • James Gupta
    James Gupta almost 11 years
    (if that fails, as an alternative when running your tests add a random variable to the URL's you're testing either via POST or GET. This essentially bypasses caching as it is a new URL each time. Common way is to get the current timestamp and go to your-url.com/page.php?rand=(current timestamp)
  • james.garriss
    james.garriss over 9 years
    Reading through the info on iOS's web inspector doesn't yield any clues on how to disable the cache. developer.apple.com/library/safari/documentation/…
  • james.garriss
    james.garriss over 9 years
    Looks like you're correct, and this is a great (and simple!) answer. osxdaily.com/2013/10/19/private-browsing-safari-ios
  • lielvilla
    lielvilla over 9 years
    In addition to Command-Shift-R, you can also use the Develop menu to disable the cache for multiple requests: developer.apple.com/library/safari/documentation/…
  • Gamadril
    Gamadril about 8 years
    Can't find the button in Safari 9.0.3 Web Inspector. Any Idea where it is?
  • Hal
    Hal about 8 years
    @Gamadril - hey - looks like its jumped up on to the main console bar and gotten much bigger. Havent really tested it out but it has the same description about clearing the cache with the shift key: Screenshot With Labelled Position
  • Chris Hill
    Chris Hill over 7 years
    This may work for your root files, but I'm finding that iOS Safari does not reload items that may be loaded via javascript calls like Angular. In instances like this you will want to install and use a proxy like Charles or Fiddler. You will also need to wipe your cache completely, because iOS Safari will still cache your files until it gets the new 'no-cache' files from the proxy!
  • Chris Hill
    Chris Hill over 7 years
    This should be the accepted answer. Using a proxy is the only way to truly disable the cache. 'Reload ignoring cache' only reloads what iOS Safari can determine as part of the initial page load.
  • Brian Burg
    Brian Burg about 7 years
    This shortcut is for "Reload Page From Origin", which doesn't actually purge the cache. It loads resources without ever consulting the cache where it normally would. The responses from a load done this way may themselves be cached for later requests.
  • Christopher
    Christopher about 7 years
    Tried my best to make Safari NOT cache files and it is stubborn. Selected Develop > Empty Caches along with Develop > Disable Caches and then also have to clear cache on device using Settings > Safari > Clear History and Website Data and also delete the file from the server until an error occurs saying the file is not present and then place the file back and reload. I imagine debugging extensive Javascript applications in Safari mobile must be a nightmare. I also had to disable caching on the server side with nginx.
  • Christopher
    Christopher about 7 years
    Another option is to perhaps create a new directory each version (e.g. test-1/... test-2/... and therefore there is no cache to access for each version.
  • atdrago
    atdrago about 6 years
    This changed to Command + Option + R (Option instead of Shift)
  • Tim Mackey
    Tim Mackey over 5 years
    This is a great solution, especially if you're just looking to do some quick testing without breaking out the developer tools. Remember though that the cache persists as long as the tab is open, so you need to close the tab and reopen it if you want to clear the cache.