Sub topic 9
What caches are and why they exist
This chapter assumes you can open Finder and System Settings, know where your home folder and its hidden Library folder are, and have seen the Storage categories from earlier chapters. Running short commands in Terminal is helpful but optional.
What a cache is
A cache is a stored copy of data that a program expects to need again. Producing the data the first time is slow or costly. Reading the saved copy later is fast. Examples:
- A web browser keeps images, scripts, and style sheets so a page loads without downloading them again.
- A photo app keeps small preview images (thumbnails) so it does not decode every full-size photo to draw a grid.
- A music or video app keeps downloaded segments so playback does not stall.
- A developer tool keeps compiled results and downloaded packages so the next build is quicker.
The key property is that a cache is derived data. The program can rebuild it from a source that still exists, such as a website, your photo library, or a package server. That property decides what is safe to delete, and it is the main idea of this chapter.
Why caches exist
Caches trade disk space for time, network use, and battery. Three costs make them worthwhile:
- Network cost. Downloading again uses bandwidth and takes time. A local copy avoids that.
- Compute cost. Rendering, decoding, indexing, or compiling uses CPU. A saved result avoids repeating the work.
- Latency. Reading from the local SSD is far faster than a network request.
Caches grow because most programs add to them freely and remove from them rarely. A cache that is never trimmed keeps its oldest entries long after they stop being useful. This is why a Mac used for years can hold many gigabytes of cache that no longer helps.
A "hit" is a request answered from the cache. A "miss" is a request that has to go to the source. Deleting a cache turns future hits into misses until the cache fills again.
Where caches live on a Mac
Caches are not in one place. The common locations are:
| Location | Owner | Typical contents | Safe to clear by hand? |
|---|---|---|---|
| `~/Library/Caches` | You | Per-app caches, browser data, thumbnails | Usually, one app at a time |
| `~/Library/Containers/<app>/Data/Library/Caches` | You (sandboxed apps) | Caches for apps from the App Store | Usually, but handled by the app |
| `/Library/Caches` | System-wide | Caches shared by all users | Leave alone unless you know why |
| `/System/Library/Caches` | macOS | System caches, protected | Never touch |
| `/private/var/folders/...` | macOS | Temporary and per-user cache files | Leave alone; macOS manages it |
| `~/.npm`, `~/.cache`, `~/Library/Caches/Homebrew` | You | Developer and package manager downloads | Yes, using the tool's own command |
The ~ symbol stands for your home folder. The next chapter covers ~/Library/Caches in detail. For now, notice the pattern: files you own, in your own Library, are low risk. Files under /System are protected by the operating system on purpose, and you should not try to remove them.
Caches versus other data
Not everything in Library is a cache. Putting the wrong thing in the "cache" mental bucket is the most common way people lose data. Compare these:
| Kind of data | Example | Can it be rebuilt? |
|---|---|---|
| Cache | Browser image cache, thumbnails | Yes, from the source |
| Preferences | `~/Library/Preferences/*.plist` | No, they hold your settings |
| Application Support | `~/Library/Application Support/<app>` | Often no. It can hold databases, saved states, and licenses |
| Documents and libraries | Photos library, Mail messages stored locally | No, unless a copy exists elsewhere |
| Logs | `~/Library/Logs` | Not rebuilt, but rarely needed |
A folder named Caches is a strong hint that its contents are disposable, because Apple's guidelines tell developers to put re-creatable data there. Some programs ignore that guidance. A few apps store real data in Application Support or even in Caches. An offline-mode feature in a streaming or notes app is a typical example. Deleting it means you download or recreate it, and sometimes you cannot.
What happens when a cache is deleted
Deleting a healthy cache normally has these effects:
- The next launch or action of the app is slower, because every request is a miss.
- The app downloads or recomputes data, so it uses network and CPU for a while.
- The cache refills, often to a similar size over time.
That last point matters for the goal of freeing space. Clearing caches gives temporary relief. If you clear a 5 GB browser cache and browse as before, it may be 5 GB again within weeks. Caches are worth clearing when one is abnormally large, when an app misbehaves because of a corrupted entry, or when you need space right now. They are a poor long-term strategy compared with removing large files you no longer need.
Deletion can also cause problems:
- Running apps. An app that has a cache file open may crash or recreate a broken file. Quit the app first.
- Corrupted state. Removing only part of a set of related files can confuse an app. Remove an app's whole cache folder, not selected files.
- Lost sign-ins. Some apps keep session data beside the cache. A related folder may log you out of a service.
Inspecting a cache before you act
Measure first. This command reports the total size of your user-level caches, as in the topic's examples:
du -sh ~/Library/Cachesdu estimates disk usage, -s gives one summary total, and -h prints human-readable units such as 4.2G. A large number alone does not mean a problem. To see which apps account for it, list the folders one level down and sort them by size:
du -h -d 1 ~/Library/Caches 2>/dev/null | sort -hr | head -n 10Here -d 1 limits the depth to one level, 2>/dev/null hides "permission denied" messages, sort -hr sorts human-readable sizes from largest down, and head -n 10 keeps the first ten lines. The top entries are the candidates to look at. The folder names are usually bundle identifiers such as com.apple.Safari or com.spotify.client, which name the app that owns them.
If you use Homebrew, you can preview what its cleanup would remove without deleting anything:
brew cleanup -nThe -n flag means dry run. It prints what would be removed and changes nothing. This habit of previewing, then acting, applies to every cache tool.
Caches and macOS's own space management
macOS manages some caches for you. When free space runs low, the system can reclaim space it labels purgeable, and some cache-like data is included there. This is why free space can rise without any action from you, as the earlier chapter on purgeable space described. It also means a manual cleanup of system-managed caches adds little. The system already treats that data as expendable, so your effort is better spent on user-level caches that macOS does not reclaim and on large files.
macOS also rebuilds some system caches on restart or when you run certain maintenance tasks, so tools that promise to "clean system caches" mostly remove files that return within days. Treat such claims with suspicion.
A decision rule for caches
Use this order when you meet an unfamiliar cache:
- Identify the owner from the folder name. If you do not recognise it, search for the name before touching it.
- Check the size. Ignore anything under a few hundred megabytes unless you are troubleshooting.
- Quit the owning app.
- Back up if the contents might matter. Time Machine, covered in the safe deletion chapter, is enough.
- Delete the folder's contents, not the folder itself, when you can. Some apps expect the folder to exist.
- Reopen the app and confirm it works. Expect a slow first launch.
Summary of the working model
- A cache is re-creatable data kept to save time, network use, or computation.
- Caches grow without limit unless something trims them, so old ones can be large and useless.
- Deleting a cache costs a slower first run and possibly a re-download, and the cache often refills.
- Location and name guide you, but only "can it be rebuilt from a source I still have?" decides whether deletion is safe.
- Measure with
du, preview with dry-run options, and clear one app at a time.
Exercise
You run du -h -d 1 ~/Library/Caches | sort -hr | head -n 5 and see a 6 GB folder named com.example.notes. The app is a notes app that has an "Available offline" feature. Should you delete the folder right away? Explain what you would check, and what you expect to happen if you delete it.
Show answer
Not right away. The name does not prove the folder is only a cache, and an offline feature may store notes there that exist nowhere else. First check whether the app syncs to a service so every note exists elsewhere, and confirm that a current backup exists. Quit the app, then delete the folder's contents. If everything is synced, expect a slow next launch and a re-download of the data, and the cache will probably grow again. If any notes exist only locally, do not delete the folder. Export the notes first or leave it alone.
Exercise
A friend says clearing /System/Library/Caches and all of ~/Library caches weekly keeps a Mac fast. Give two reasons this advice is weak.
Show answer
First, caches exist to make repeated work faster, so clearing them forces apps to rebuild them and often makes the Mac slower after each clear, while the space returns as caches refill. Second, /System/Library/Caches is protected by macOS and managed by the system, so you cannot and should not remove it by hand. Space the system treats as purgeable is reclaimed automatically when needed, so a weekly manual clear gains little and adds risk.