Mac users probably know that macOS — like other operating systems — uses lots of cached files. A cached file contains temporary data created by a variety of apps that you use, such as primarily browsers.
What Is Cache?
Your Mac stores different types of temporary files, for example the cache files of the system, the web browser, messaging apps, and user data as well as those generated and stored by apps or files and partially completed downloads. Sometimes these files get corrupted because of software updates, causing problems at launch.
These temporary files aim to help your Mac run faster. For example, if you visit a web page, macOS creates a storage area on your hard drive to hold the most recently downloaded con-tent for that site. By default, web browsers cache all content such as text, images and other content encountered on the internet. To enable quicker access the next time you visit the same page, your web browser uses your computer's memory to store the data of recently visited web pages.
Caching those web pages allows you to quickly jump from one web page to another without the need to download that page again. When you have finished browsing, the cached pages are stored on your disk drive. Some web browsers, such as Mozilla Firefox, let you set the amount of space to use for the cache, – which is essentially a separated folder – and the length of time to hold the pages. However, the majority of web browsers don't allow this feature.
Helpful But Sometimes Painful
Part of your Mac's performance depends on empty hard drive or flash drive space. In order to work at its best, your Mac needs around 10% of your storage space available. So, while helpful, the problem with these temporary files is that they won't disappear after we use them. They remain on your Mac and, over time, the number of temporary files builds up and could consume several gigabytes of storage if not cleared. A cache can be compared to trash: it's good to take it out on a regular basis, otherwise you won’t be able to move because you’ll be surrounded by it.
While some apps can handle cache management on their own, more advanced users can maintain their Mac's storage space by manually clearing their own cache and temporary files. Generally, this isn't a task you'd do regularly unless you notice that the cache is taking up too much space or a particular app is not functioning properly or serving up data from an old cache.
Despite what Mac cleaning apps claim, emptying the cache won't magically speed up your computer's performance. It will reclaim storage space, that's for sure, but don't expect a phenomenal performance boost. It will help certain apps perform better. And if you clear the cache manually, you should first back up your Mac first using Time Machine, because this gives you the option of restoring your data if something goes wrong.
How Do I Manually Clear Cache Files on My Mac?
There are three main types of cache data you can clean on your Mac: the user cache, the system cache – which includes the app and DNS caches – and the browser cache.
To clear your user cache, you first need to quit any active Mac apps, and then:
- Open a Finder window.
- Hold down the Alt/Option key, and click on the “Go” menu in the Finder.
- Select “Library” from the drop-down menu items.
- Look for the “Caches” folder inside the “Library” folder.
- Select the caches and temporary files you want to clear, or select all if that's your prefer-ence, and then move those items into the Trash.
- Empty the Trash in macOS as usual, and you're done.
A faster way to access the cache folder is to open a Finder window, click on the “Go” menu and select “Go to Folder”, then type in
~/Library/Caches in the dialog box.
After emptying the Trash following steps 5 and 6, you can also repeat the “Go to Folder” command but this time enter just
/Library/Caches and repeat steps 5 and 6.
Another way to access that last Cache folder is to open a Finder window, use the Cmd+Shift+C short key, then click on “Macintosh HD” and select “Library” then “Cache”.
The safe way to clear temporary items and /private/var/folders/ is very simple: just reboot your Mac. That will trigger Apple's operating system's built-in cache clearing functions, and the temporary items in these folders will be deleted automatically.
It is recommended that you reboot your Mac after clearing the cache manually.
System, DNS Cache
Another system cache that has a tendency to build up is the DNS cache, which contains old entries that translate domain names to IP addresses. Flushing the DNS cache could help websites load properly.
To clear the DNS cache using Terminal, do the following:
- Launch Terminal (tip: type “terminal” into Spotlight).
- If you are running macOS Sierra, type in the following command:
sudo killall -HUP mDNSResponder;say DNS cache has been flushed
The command includes instructions for a verbal audio alert to signal that the DNS cache has been flushed when the action is complete.
Older versions of macOS usually have different sudo commands for resetting the DNS cache.
The only web browser of the most popular browsers (think Google Chrome, Safari, Firefox, Opera) that allows users to set the cache size is Firefox. But all browsers include an option to clear the cache. For Apple's built-in Safari you’ll need to activate the “Develop” menu under Preferences, so it requires an extra step first.
Clearing the Cache Simply Using Third-Party Apps
If you don't want to go through all the steps listed above, you can always rely on a third party app such as CleanMyMac, MacKeeper, OnyX or others, which will make the process easier. These third party apps don't require advanced macOS knowledge from the user, and they usually come with a nice, clean user interface.
For example the popular third party Mac optimization software CleanMyMac enables users to find and remove all the cache files simply by hitting one button. With CleanMyMac, for example, you launch the app, select “System Junk” from the left menu items, hit “Scan” and then “Clean”, and the software does the rest.