Oooh, new project: symlink .cache to /tmp, forget all tf about it, reach mental brink trying to figure out why the hell all this odd crap is goin wrong.
XDG Base Directory Specification
[...]
There is a single base directory relative to which user-specific non-essential (cached) data should be written. This directory is defined by the environment variable $XDG_CACHE_HOME.
[...]
If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used.
The XDG Base Directory Specification (XDGBDS) defines four categories of so called DotFiles and the corresponding directories in a user's home directory that should be used for those. The categories are cache, configuration, data and runtime files. There is not yet a separate categorie for "state" files although such a categorie has been requested several times
The state category was added in the latest version of the standard, which is 0.8.
You mention down-thread that specific programs are badly behaved - setting the environment variable only when you run the misbehaving program, and leaving the cache where it is, might solve your problem without broader impact.
Did a columns get misplaced, DATA is on the topics. All row titles should be +1. Moving CACHE to no for 'backup' and yes for 'can live in tmpfs'.
Incidentally I've been having a tmpfs fstab entry for $XDG_CACHE_HOME for many years and never had any issues. Good to know it actually matches the specification :) up-voting for references!
There is a non-breaking space on the first column. Looks like the new reddit doesn't like it, but it's working fine on old reddit. The entire markdown parsing is a mess on both reddit versions. Really annoying. Let me fix it real quick. The data however is copied correctly from the debian wiki page. If you don't agree with one of the values, that's fine though.
I assume you want to point it at /tmp because you want to wipe your caches frequently.
But why?
A cache is a space-time tradeoff, as in it makes your programs faster at the cost of some disk space. So clearing your caches will just make your programs slower. And surely the amount of space it takes up isn't a problem.
This notion of clearing your caches as regular system maintenance is totally wrong, and I hate that it has spread so much.
The only actual reasons you would need to clear your caches are:
You are running out of disk space. Clearing your cache is a temporary solution until you can either get more storage or clean up your drive in some other way.
Your program is misbehaving. A poorly designed program can be incompatible with a cache created by an older version, and this incompatibility could manifest in weird ways. Or you could mess around with some configuration that invalidates the cache in a way that requires manual intervention. Both of these cases are highly unlikely with well designed software.
Privacy. If a third party will have temporary read access to your drive, you may want to clear your caches before you grant that permission. Note that this is a one-off case. If that third party will have persistent access, then your privacy is compromised regardless of caching, so you might as well keep the caches around.
31 points
unknown author9 hidden
Two programs are throwing junk into ~/.cache and never deleting it so its 16+GB for no reason. One generates random folder names so I can't just link the folder it uses
The .cache dir in your home stores cache from your apps. If u delete and send all to /temp everytime u reboot that will be wiped, you must dont do that.
It all depends on many factors. Your storage, your media containing your home directory, the applications you use etc. Etc.
I have a Void installation on an 8GB usb storage, I use it whenever im not on my own pc (a slow linux is better than windows) on that one, .cache is defined as tmpfs in my fstab. Meaning that it is mounted on RAM. (The same as pointing it to tmp)
On my gentoo installation, I point it to RAM when I want to compile something heavy, then reduce my compilation tasks by one (I dedicate two GB to .cache) this way emerge can access my source files on the fly and makes compilation at least 30% faster compared to having one more compiler task at a time. (The same with compiling AUR packages on ARCH)
Cache is usually meant to be used for temporary files, download parts, somewhere to store data that will be discarded/not needed soon. SO, basically losing .cache folder is totally fine and all your apps would work perfectly fine. But there are softwares (usually ported from windows) that treat .cache folder like Users\AppData folder of windows and store their data there, like a good amount of ported games store their save files there. That is when mounting your .cache on RAM would be a disaster.
A rule of thumb: rename your .cache to .cacheOLD and restart, try all your apps and see if any of them misbehave. if all of them are working fine, be my guest, make a symbolic link and create a new .cache folder that resides in tmp (or define it as tmpfs in fstab, if you have enough ram)
If you noticed any misbehaviour, just remove the new .cache folder, and rename .cacheOLD back to .cache , everything will be back to the way it was before
3 points
unknown author
If cache becomes a problem again I'll try renaming and doing what you suggested
I like how you ignored all of the advice here to reply to the one person telling you how to do it - and got downvoted do that advice. This oughta go well.
47 comments
Yes.
Only if you thoroughly enjoy loading screens and weird behavior.
Oooh, new project: symlink .cache to /tmp, forget all tf about it, reach mental brink trying to figure out why the hell all this odd crap is goin wrong.
Deleted before we saved it.
seems like you speak from experience my good sir
Deleted before we saved it.
Deleted before we saved it.
Because things need to store cache somewhere, and sure, you can, if you don't mind it being wiped when you shut down the machine.
When you do WHAT with your machine?
Deleted before we saved it.
Pop quiz hotshot. Your computer is running at 3.2 GHz and the minute you shut it down, you lose all your user cache. What do you do? What do you do?
I feel like I'm missing a reference here?
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
https://wiki.debian.org/XDGBaseDirectorySpecification
The state category was added in the latest version of the standard, which is 0.8.
Good to know!
You mention down-thread that specific programs are badly behaved - setting the environment variable only when you run the misbehaving program, and leaving the cache where it is, might solve your problem without broader impact.
Did a columns get misplaced, DATA is on the topics. All row titles should be +1. Moving CACHE to no for 'backup' and yes for 'can live in tmpfs'.
Incidentally I've been having a tmpfs fstab entry for $XDG_CACHE_HOME for many years and never had any issues. Good to know it actually matches the specification :) up-voting for references!
There is a non-breaking space on the first column. Looks like the new reddit doesn't like it, but it's working fine on old reddit. The entire markdown parsing is a mess on both reddit versions. Really annoying. Let me fix it real quick. The data however is copied correctly from the debian wiki page. If you don't agree with one of the values, that's fine though.
Its usually a bad idea to put the cache in
/tmp. A smart application will understand/tmpis of limited size and avoid putting massive files in there.I assume you want to point it at
/tmpbecause you want to wipe your caches frequently.But why?
A cache is a space-time tradeoff, as in it makes your programs faster at the cost of some disk space. So clearing your caches will just make your programs slower. And surely the amount of space it takes up isn't a problem.
This notion of clearing your caches as regular system maintenance is totally wrong, and I hate that it has spread so much.
The only actual reasons you would need to clear your caches are:
You are running out of disk space. Clearing your cache is a temporary solution until you can either get more storage or clean up your drive in some other way.
Your program is misbehaving. A poorly designed program can be incompatible with a cache created by an older version, and this incompatibility could manifest in weird ways. Or you could mess around with some configuration that invalidates the cache in a way that requires manual intervention. Both of these cases are highly unlikely with well designed software.
Privacy. If a third party will have temporary read access to your drive, you may want to clear your caches before you grant that permission. Note that this is a one-off case. If that third party will have persistent access, then your privacy is compromised regardless of caching, so you might as well keep the caches around.
Two programs are throwing junk into ~/.cache and never deleting it so its 16+GB for no reason. One generates random folder names so I can't just link the folder it uses
Deleted before we saved it.
What programs?
The .cache dir in your home stores cache from your apps. If u delete and send all to /temp everytime u reboot that will be wiped, you must dont do that.
If you mean .cache in your user directory, that is meant to store GPU cache, the songs you listen in Spotify, and other similar stuff.
/tmp is emptied every time you reboot, so it wouldn't be wise to have your cache files there.
No, that’s generally a bad idea. It contains, as the name indicates, cached data that applications use between runs.
/tmp is usually mounted onto memory, do won’t survive reboots. You’ll be eating up memory and everything we’ll be slower after every reboot.
If you want to move it, read the XDG basedir spec, the cache location is controlled via an environment variable.
It all depends on many factors. Your storage, your media containing your home directory, the applications you use etc. Etc.
I have a Void installation on an 8GB usb storage, I use it whenever im not on my own pc (a slow linux is better than windows) on that one, .cache is defined as tmpfs in my fstab. Meaning that it is mounted on RAM. (The same as pointing it to tmp)
On my gentoo installation, I point it to RAM when I want to compile something heavy, then reduce my compilation tasks by one (I dedicate two GB to .cache) this way emerge can access my source files on the fly and makes compilation at least 30% faster compared to having one more compiler task at a time. (The same with compiling AUR packages on ARCH)
Cache is usually meant to be used for temporary files, download parts, somewhere to store data that will be discarded/not needed soon. SO, basically losing .cache folder is totally fine and all your apps would work perfectly fine. But there are softwares (usually ported from windows) that treat .cache folder like Users\AppData folder of windows and store their data there, like a good amount of ported games store their save files there. That is when mounting your .cache on RAM would be a disaster.
A rule of thumb: rename your .cache to .cacheOLD and restart, try all your apps and see if any of them misbehave. if all of them are working fine, be my guest, make a symbolic link and create a new .cache folder that resides in tmp (or define it as tmpfs in fstab, if you have enough ram)
If you noticed any misbehaviour, just remove the new .cache folder, and rename .cacheOLD back to .cache , everything will be back to the way it was before
If cache becomes a problem again I'll try renaming and doing what you suggested
Deleted before we saved it.
https://wiki.archlinux.org/title/Tmpfs
https://man.archlinux.org/man/tmpfiles.d.5
You can use tmpfs to automatically create and remove or clean a directory.
I've pointed it to /tmp for years as per the tmpfs archwiki.
/etc/fstab e.g.
tmpfs /tmp tmpfs rw,nodev,nosuid,size=2G 0 0Works for me, I have 24GB RAM, never see more than 17GB RAM used. I have the tmpfs set to 10GB.
How do you point it?
ln -s /tmp $HOME/.cache?I like how you ignored all of the advice here to reply to the one person telling you how to do it - and got downvoted do that advice. This oughta go well.
Don’t do that lol
Oops, I miswrote my /etc/fstab entry. Here it is:
tmpfs /home/momasf/.cache tmpfs rw,noatime,nodev,nosuid,size=10G 0 0As to others saying it's not recommended - please say WHY. After all, https://www.reddit.com/r/archlinux/comments/nz3fhm/is_it_safe_to_delete_cache/ has the top reply as saying that it's fine and that comment has 62 thumbs-up.