Clearing Your Mac Safari Browser Cache

Safari keeps a cache of files to speed up page loading and minimize bandwidth usage. For the most part it maintains itself. But if you need to clear the cache while publishing or developing a website, you can do so using one of several methods in Safari. You can clear all data from a specific site, enable the Develop menu to clear the cache with a keyboard shortcut, or manually delete the cache files in the Finder.
Video Transcript / Captions
Closed captioning for this video is available on YouTube: Clearing Your Mac Safari Browser Cache.

What is a browser cache? A browser cache is when an image or some other element on a page is downloaded and saved in a temporary local file so if that image is needed again it doesn't have to go and redownload that entire thing. For instance a website like MacMost will have a logo graphic at the top. If you visit a bunch of different pages at MacMost it's the same logo graphic. Why download it individually each time. It's going to use up a lot of bandwidth. It's going to slow down loading of the page. So it recognizes that the same graphic is used from one page to the next and looks at the cached version it has.

Now caches maintain themselves. When files get too old in there Safari gets rid of them. When you're short on space Safari gets rid of them. So there's really nothing you need to do to maintain the cache of your browser. For the most part it just operates independently. It's not one of those things you need to worry about. But every once in a while there's a reason to clear the cache because what if the image is changed. An image is changed and there's no way for the browser to know that. It's going to say, hey it looks like the same image to me. I'm not going to go and download a new version. But if the server has a new version of that same image with the same name then it can't really know.

So in some cases you may need to change it. Like an example may be a weather widget on a site that's an image showing you today's weather and it's going to change the next day. But maybe it has the same file name. You're just going to get the old image instead of the new one. Here's an example here where, say I'm working on my website and I have an image here on a page and I'm going to change it on the server. I'm going to update the server here and change it so it's a new image that has the number 2 in it instead of the number 1.

Now look what happens when I refresh the page. I'm going to hit the reload this page button here and it's still going to show me the number 1 in there. But I know the image has been changed on the server. So I want to clear the browser's cache.

One way to do this is to go to Safari, Preferences. From there click Privacy. You see where it says Manage Website Data. Bring that up and this will allow you to clear the cache only for that one website. Now you can click Remove All and it will remove all the caches for all the files in all the sites. But it will also remove cookies and things like that which you don't necessarily want. It means you might be logged out of a lot of websites and you might have some prefilled stuff that disappears.

But if I wanted to I can select MacMost here and I hit Remove and I remove the cache and cookies from MacMost and then I can hit Done. Close that and now when I refresh this page this doesn't have a cached version of this image. It should seek out a new one. You can see now it gets the correct one from the server.

Now there's another way to clear caches. If this is something you need to do a lot, like you're a developer and you're changing the images you have on your server a lot, or even if you're just a publisher. You're just publishing to a blog a lot and you want to make sure you see the updated graphics there, you can go to Safari, Preferences, and then click on Advanced. Then click Show Develope Menu in the Menu Bar. Now that you have that on you've got this extra menu here. You can see there is an Empty Caches item there. The keyboard shortcut for it is Option, Command, E. So you can either select that or you can use Option, Command, E if it's something you do a lot to clear all the caches. The great thing about that is it doesn't clear the cookies and other things like that. It just gets rid of the cached files.

Now I want to show you a case where this doesn't work. When you go to Preferences, and you go to Privacy, and you go to Manage Website Data, and it brings up something and you notice there's two websites here that have data there. I'm going to select Remove All to get rid of everything there. You think, great, it's cleared all my cache and all my cookies. But hold on a minute because if you wait a second those two sites appear again. What's happened there? Well, it's just a glitch. It's a bug that's been around in Safari for a little while. I think most of the stuff, the cache and the cookies have been removed but certain types of databases that are used, you know probably just to remember like who you are if you're plugged into those sites. That kind of thing. They stay there and it can be a little bit annoying.

So if you really want to clear the cache out and you want to do it right from the source here's what you do. Go to the Finder and you go to the Go menu but you hold the Option key down so you can select Library. This will bring up a window here that is your Library. In your Library you can go down into Safari. From Safari you go to Databases and then there's usually a folder in there. In here is where you see some folders. You can see those are the two sites that had trouble getting rid of. So I can select those two folders, Delete, and now they should be gone. If I go to Safari, Preferences, and I go to Manage Website Data, nothing should show up because I've removed those folders.

So if you run into that glitch which happens every once in a while with a certain type of data file but you really want to clear out all your cache, that's the way you do it.

Comments: 12 Responses to “Clearing Your Mac Safari Browser Cache”

    Douglas Brace
    10 months ago

    Gary, besides the ability to pick-and-chose individual website or Internet locations, what is the difference between going to (a) “Safari Preference…” > “Privacy” > “Manage Website Data…” to clear your cache and going to (b) “Safari Menu” > “Clear History…”? I ask because the “Clear History…” option says “Clearing history will remove related cookies and other website data” and going into “Safari Preferences” seems to require extra steps.

    10 months ago

    History is something different. It is the list of pages you have visited recently. Just links. It doesn’t take up much space. It is just so you can go back to a page you visited. The cache is data and media stored to make viewing other pages at the same site faster. Think of it like this, if it were books: The History is like a piece of paper with a list of the books you have. The Cache is the actual books.

    10 months ago

    Gary – When I clear the cache from Safari preferences does it also clear the Google Chrome cache? Thanks!

    10 months ago

    Robin: No. Separate apps, so separate caches.

    Chris Caldwell
    10 months ago

    Gary, I keep trying to delete the website data from the privacy tab in safari preferences. Everyday, a certain website shows up in the cookies file. How do stop this? I’ve tried going to the cookies file folder and deleting the site from there too. Nothing works. It reappears every day. Thank you

    10 months ago

    Gary, it is very useful topic for me to understand how safari (or other browsers) works… However, my question is what if I delete Library > Safari > Database, everything under this folder. What is the actual result of this action? Will it kill all entries (e.g. password related) to these sites, we saved before..? Is this because I am living problems about entering my online bank account for a while (several months I guess)..? … …
    Thank you…

    10 months ago

    Ertugrul: Deleting that would erase information that the site is storing, but I can’t know what exactly. Only the site developer would know. But instead of that, just use Safari, Preferences, Privacy, Website Data and search for and delete only that site. Then it would just clear the information about that site. Don’t know if that will help your problem, though. You may need to also check Safari, Preferences, Passwords and look for that site.

    10 months ago

    Chris: So when you visit the site, a new cookie appears? That’s normal. Or, if you visit a site and that site accesses a third-party site (like an ad network). Normal too. What is your concern?

    Jean-Pierre A Zacaropoulos
    10 months ago

    Would appreciate if you could do the same for Google Chrome.
    Thanks in advance.

    10 months ago

    Jean-Pierre: In Chrome it is just Chrome, Preferences, Advanced, Clear Browser Data.

    Dr Ashish Jain
    10 months ago

    When I look at the pull down menu of GO I do not see Library there , what do I do?
    Which option will delete even the passwords stored by the safari ?

    10 months ago

    Ashish: While looking at the Go menu, hold down the Option key on your keyboard. If you want to delete passwords from Safari, go to Safari, Preferences, Passwords.

Comments Closed.