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.