12

The .cache directory is full of volatile, non-essential files.

I would like to move it to a more appropriate partition, i.e. faster and not backed up.

I believe that ~/.pam_environment file is appropriate for this but am not sure if is the best or if it is documented properly or working properly.

2
  • How are you preserving /some/other/place/.cache between reboots? If one moves .cache to, say, /dev/shm, when the box is rebooted /dev/shm/.cache is missing and so ~/.cache is dangling symlink. – user257772 Mar 13 '14 at 8:06
  • Related guide for google chrome here: joeyconway.com/blog/2011/09/11/… – Kzqai Feb 23 '16 at 18:31
22

If you don't care about keeping the stuff there across reboots, you can use tmpfs to store the cache.

Set something like the following in /etc/fstab:

tmpfs /home/someuser/.cache tmpfs defaults,size=512M 0 0

Now, your .cache will be stored in memory instead of on disk, though if you have insufficient memory it could end up being swapped out.

A more traditional approach would be to move the directory to wherever you like and symlink it as appropriate:

mv ~/.cache /some/other/place
ln -s /some/other/place/.cache ~/
4
  • This is working well. I had hoped to use pam-env as it is the "preffered" way, but this works, and if it isn't broke, don't fix it. BTW Chrome is much speedier now! – keepitsimpleengineer Dec 24 '11 at 17:21
  • ~/.pam_environment is for setting environment variables, which has nothing to do with the task at hand. Besides, though some claim that .pam_environment is preferred, I don't think that's necessarily so, considering how few people (according to Google) are using it. .bashrc is good enough for me. – Scott Severance Dec 25 '11 at 1:42
  • 1
    I think second option have one error, second line should be ln -s /some/other/place/.cache ~/.cache, not just link to ~/, how apps will know home is cache folder, not old .cache inside home? – Alexei Martianov Mar 14 '18 at 12:39
  • 1
    If no filename is specified, then ln will use the original one. So, while your example will also work, there's no mistake in my answer. – Scott Severance Mar 14 '18 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.