Sub topic 10
Clearing user caches in ~/Library/Caches
This chapter assumes you can use Finder and Terminal at a basic level. You should know what the home folder and the hidden Library folder are, and you should have read the earlier chapters on Storage settings, large files, and safe deletion. The earlier chapter on what caches are explains why they exist. This chapter covers how to inspect the user cache folder, decide whether to clear it, and do so without causing damage.
What lives in ~/Library/Caches
Every app you run can store temporary data in ~/Library/Caches. The ~ stands for your home folder, so the full path is something like /Users/yourname/Library/Caches. Each app usually gets one subfolder, named after its bundle identifier. A bundle identifier is a reverse-domain name that uniquely identifies an app, such as com.apple.Safari.
Typical contents:
- Downloaded thumbnails and previews
- Compiled or pre-processed data the app can regenerate
- Web content stored by browsers
- Update packages and installer leftovers
- Logs or crash data kept by some apps
Two other cache locations are easy to confuse with this one:
| Location | Scope | Safe for you to edit? |
|---|---|---|
| `~/Library/Caches` | Your user account only | Usually, with care |
| `/Library/Caches` | Shared by all users on the Mac | Needs admin rights, and is riskier |
| `/System/Library/Caches` | Part of macOS itself | No. Leave it alone |
This chapter covers only the first row. System-level caches are protected for a reason, and macOS rebuilds or manages them itself.
Measure before you delete
Clearing caches rarely frees as much space as people expect. On many Macs the folder is a few hundred megabytes to a few gigabytes. Measure it first so you can decide whether the effort is worthwhile.
du -sh ~/Library/CachesThe -s option prints one summary total for the folder, and -h prints it in readable units such as 2.3G.
To see which apps use the most, list the subfolders by size:
du -h -d 1 ~/Library/Caches 2>/dev/null | sort -hr | head -n 10This is the same pattern used earlier for your home folder. -d 1 limits the report to first-level folders, sort -hr sorts human-readable sizes from largest to smallest, and head -n 10 keeps the top ten. The 2>/dev/null part hides permission errors, which appear for folders that macOS protects.
If a Terminal command reports "Operation not permitted" for some folders, Terminal may lack Full Disk Access. You can grant it in System Settings under Privacy & Security, but you do not need to for this task. The folders you can read are the ones you can safely manage anyway.
What is safe to clear, and what is not
A cache is data an app can rebuild. The rule that follows is simple, but the edge cases matter.
Usually safe to clear:
- Browser caches for Safari, Chrome, or Firefox
- Thumbnail and preview caches
- Caches of apps you rarely use
- Leftover folders from apps you already uninstalled
Be cautious with:
- Apps that are currently open. They may be reading or writing their cache.
- Apps that store sign-in tokens, license data, or offline content in
Caches. A few apps misuse the folder for data that is not truly disposable, such as downloaded offline media for streaming or reading apps. - Cloud sync clients. A partial sync state may be kept there, and clearing it can force a long re-scan or re-download.
- Anything under
com.apple.*that you do not recognize. Many of these are managed by macOS, and removing them can cause odd behavior until they are rebuilt.
Never do this:
- Delete the
Cachesfolder itself. Delete the contents of individual app subfolders instead. - Touch
~/Library/Application Support,~/Library/Preferences, or~/Library/Containersas part of a cache cleanup. Those hold settings, documents, and app data that cannot be rebuilt.
A safe step-by-step routine
The following routine keeps each action small and reversible.
- Back up first. Confirm that your most recent Time Machine or other backup finished. Safe deletion practices from the earlier chapter apply here too.
- Quit the apps whose caches you plan to clear. Include background helpers if the app has a menu bar item.
- Measure the folder with
du, as shown above. - Pick targets. Choose the largest subfolders that belong to apps you recognize.
- Move to Trash, do not delete permanently. In Finder, select the contents of the subfolder (not the subfolder), drag them to the Trash, and keep them there for a few days.
- Restart the app and confirm it works. It may feel slower for the first launch while it rebuilds its cache.
- Empty the Trash once you are satisfied. Space is only returned after this step.
Using Terminal instead of Finder
If you prefer the command line, you can preview what a subfolder contains before you remove anything. Replace com.example.app with a real folder name from your own listing.
ls -la ~/Library/Caches/com.example.app
du -sh ~/Library/Caches/com.example.appTo move the contents to the Trash rather than deleting them, the safest approach is still Finder. The rm command removes files immediately and does not use the Trash, so a mistake cannot be undone except from a backup. If you do use rm, two habits reduce risk:
- Quote paths, because folder names can contain spaces.
- Never combine
rm -rfwith a variable that might be empty. An unset variable can turn a narrow path into a broad one.
Here is a short script that deletes the contents of one named cache folder, with checks. It refuses to run if the target is missing or is not inside your user cache folder.
#!/bin/bash
set -euo pipefail
target="${1:-}"
base="$HOME/Library/Caches"
if [ -z "$target" ]; then
echo "Usage: $0 <cache-folder-name>" >&2
exit 1
fi
# Reject path separators so the name cannot escape the Caches folder.
case "$target" in
*/*|.|..)
echo "Give a folder name only, not a path." >&2
exit 1
;;
esac
dir="$base/$target"
if [ ! -d "$dir" ]; then
echo "Not found: $dir" >&2
exit 1
fi
echo "Size before:"
du -sh "$dir"
read -r -p "Delete the contents of $dir permanently? [y/N] " answer
if [ "$answer" = "y" ]; then
find "$dir" -mindepth 1 -delete
echo "Done."
else
echo "Cancelled."
fiSave it as clearcache.sh, run chmod +x clearcache.sh, then run ./clearcache.sh com.example.app. The find ... -mindepth 1 -delete command removes everything inside the folder but keeps the folder itself, which many apps expect to exist.
Why space may not appear right away
You may clear a gigabyte and see Storage settings barely change. Common reasons:
- The Trash was not emptied. Files in the Trash still use space.
- Storage settings update slowly. Reopen the pane or wait a minute.
- The cache was already counted as purgeable. macOS can reclaim some cache data on its own when space runs low, so clearing it by hand frees less than it appears to.
- A running app recreated the cache. Browsers and chat apps often rebuild the data immediately.
To verify the result, run the df command from the earlier chapter, and compare the "Available" figure before and after:
df -h /System/Volumes/DataTrade-offs and expected behavior
Clearing caches is a trade. You gain disk space now, and you pay in time the next time each app rebuilds its data. A browser may reload pages and images more slowly. A photo or video app may regenerate thumbnails for minutes. Apps that compile data, such as some creative tools, may be slow on first launch.
For this reason, clearing caches is a poor routine to run weekly. It is most useful when:
- You are short on space and need a quick, low-risk gain.
- One app has an unusually large cache, for example several gigabytes.
- An app behaves oddly and a stale cache is a plausible cause.
If the numbers are small, leave the caches alone. Large files, old downloads, and unused apps usually return far more space for the same effort.
Common errors
- Deleting the whole
Libraryfolder or theCachesfolder. Remove only the contents of specific app subfolders. - Clearing caches while the app runs. The app can crash, or recreate the files at once.
- Using a "cleaner" app that removes everything it labels as junk. Many such tools delete data that is not a true cache. Prefer the manual steps above.
- Assuming a restart clears caches. A restart clears some temporary system data, but it does not empty
~/Library/Caches. - Running
rm -rfon a path built from a variable that was never set. Useset -uin scripts and check the value first.
Exercise
You run du -h -d 1 ~/Library/Caches | sort -hr | head -n 5 and find that a folder named com.example.musicplayer is 6 GB. List the steps you would take before and after clearing it, and name one reason the app may not be safe to clear by hand.
Show answer
Back up first, quit the music player, and look inside the folder with ls -la and du -sh. Check the app's own settings for a clear-cache option and use it if present. If you clear by hand, move the contents (not the folder) to the Trash, relaunch the app, confirm it works, then empty the Trash and check free space with df -h /System/Volumes/Data. One risk is that music apps often store downloaded offline tracks in their cache folder. Deleting those removes content you must download again, and it may need an internet connection or a valid subscription.
Exercise
Why does the script in this chapter reject a target name that contains a slash, and why does it use find "$dir" -mindepth 1 -delete instead of rm -rf "$dir"?
Show answer
Rejecting slashes stops a value such as ../Application Support from pointing outside ~/Library/Caches. Using find ... -mindepth 1 -delete removes the contents but leaves the app's folder in place, which many apps expect to exist. It also avoids rm -rf on a path built from a variable.