# How do I truly flush Safari's cache?

There have been countless times where I run into a problem after I edit HTML on a Mac. The issue derives from me uploading the updated file to my server through FTP, and I'll navigate to the website in Safari. The one thing that didn't act properly was that Safari had already cached the webpage (the old version), so it would display the old version. I thought to myself and decided to clear the cache in Safari hoping it would solve my issue. Clearing the cache merely let the website appear to reload. It still came up with the old version of the file. To prove that the file on the server was actually updated, I got on another Mac on the same network, and it displayed the new version of the file. No matter how many times I refreshed or cleared the cache or reopened Safari, it would always deliver the old file. The only other solution I could come up with was to reboot. After a reboot, Safari reloaded the entire website and displayed the new version of the file.

I'm really just wondering how to flush Safari's cache and have it behave properly. Is this something the operating system does (I've had similar problems with files on my harddrive, too)? I don't want to have to reboot all the time just to see a new version of a file, so is there any way I can ensure I'm viewing the newest one? Is there a temporary storage folder that I can manually clear out? This happens to me quite often (not terribly frequent, but enough for me to notice), and my only current solution is to reboot.

I have strange feeling (it's not really a thought, but an ever so slight possiblilty that doesn't make much sense) that it's originating from a lower level.

• Use chrome (or opera)? – Fake Name Mar 30 '12 at 6:44
• I'd rather use Firefox, but I'm developing, so I need to test out my website on all browsers including Safari. – Andrew Larsson Mar 30 '12 at 15:42
• It can be useful to use the curl command-line command to request a URL, to see what it comes up with. The old page or the new? Since curl has no concept of "caching" anything at all, this will tell you if someone on the remote side (or the path between) is doing caching that you don't want. Your server just might be the actual culprit here! Is it caching the files that it serves? Betcha it is . . . – Mike Robinson Sep 14 '18 at 15:28

In Safari, hold down down the (Shift) key while clicking the refresh button. This will perform a “hard” refresh, which bypasses the local cache.

(To quickly clear the cache in Safari, hit ++E, go to Privacy, and click “Remove All Website Data”.)

• I'll definately try that next time I run into this issue. That's one thing that I haven't done yet. I've tried resetting Safari, clearing the cache, and even logging out and logging back in. Thanks for the great answer! – Andrew Larsson Mar 30 '12 at 5:40
• Safari is a bit confusing in this aspect, as most other browsers use ⌘+⇧+R to perform a hard refresh. In Safari, that doesn’t do anything, unless you focus the Web Developer Tools while performing the keyboard combo. – Mathias Bynens Mar 30 '12 at 5:42
• I'm going to accept your answer for now until somebody comes along with a better explanation with a proven solution to the ignorant caching I'm experiencing. Thanks! – Andrew Larsson Mar 30 '12 at 5:45
• @AndrewLarsson Anyway, after a hard refresh you should always get the latest version, assuming there’s no weird server-side caching going on. Which reminds me, what caching headers does the server send along with the file? It could be a server configuration issue. – Mathias Bynens Mar 30 '12 at 5:46
• That was another thing I was thinking. If the server is returning a 304 when, in fact, it should be returning new content, it'd be something I need to change in my configuration. I'll investigate this the next time I come across this problem. – Andrew Larsson Mar 30 '12 at 5:50

When Safari doesn't clear cache:

1. Ensure that you have logged out of all webpages, and have closed all the Safari tabs.

2. Open Finder and select Go → Go To Folder... in Menu bar. (Alternatively, you can use the keyboard shortcut, Command + Shift + g.)

3. Copy and paste the following into dropdown:

~/Library/Safari/Databases

4. Delete all the contents that appear in that folder by highlighting all folders and right clicking and selecting Move to Trash.

5. Open Safari again and check that all item are now deleted.

6. If nothing appears when you search for the above criteria, please search

~/Library/Safari/Local Storage

and follow steps 4 & 5 above to delete all the contents.

• Note that although Safari says, above, that it will "Remove All Website Data," the truth is that it really doesn't. But if you purge the contents of the various folders mentioned here, it will. – Mike Robinson Sep 14 '18 at 15:25

I had the exact same problem except I noticed that it was happening with other browsers too. As it turns out it was not Safari or OSX it was a cache created by the service provider.

To solve the problem I put code in my page to prevent it from being cached.

content="no-cache"

"Some people know about the browser caching, but still get taken aback by ISP caching. ISP caching works in much the same way as browser caching. Once you have visited a website your ISP may cache those pages so that they appear to load faster the next time you visit them. The main problem with this is that unlike your browser cache you can not delete these temporary files, instead you have to wait until your ISPs cache expires and it requests fresh copies of the files. This can be very frustrating if you are trying to develop or make changes to your website -- or even to look at new information."

• Can you please put back to full code (as you had in the first version of the answer)? If you put four spaces at the beginning of the line, there shouldn't be any problems with formatting. – nohillside May 27 '13 at 11:37
• This is a good point, and I'll try it next time. However, I'm not sure how well it would apply to the situation I described in the question, because the Macs I used were both on the same network and had the same global IP (so the ISP wouldn't be able to determine the difference between the them). – Andrew Larsson May 28 '13 at 20:29