I'm about to back up some parts of my filesystem, including my home directory. I'm looking at $HOME/.cache, and wondering what I should do with it. I know that it's safe to just delete it altogether, but I also notice that most of the space is taken up by the web browser cache. So - of course not deleting caches meaning less time to recreate them, but is there some significant benefit which might make it worth it to keep some of the subdirectories of $HOME/.cache and just delete the browser cache (chromium and mozilla in my case)?
- 8,772
- 19
- 65
- 129
2 Answers
Two benefits come to mind (which, to me, aren't that compelling — I don't back it up):
If you back up everything, then you have everything. Even if the program's author thinks your critical data is actually ephemeral, easily recreated, cached data. Or, when you're doing backups for other people, if the user thought
~/.cachewas a great place to store his cache of essential documents.It takes time to recreate cached data, that's why it's saved in the first place. So by backing it up, you're avoiding having to wait for it to be re-generated (or redownloaded, etc.)
There are of course a bunch of obvious drawbacks (backup size, backup time), some less obvious ones (privacy), and some gotchas (programs that presume that an image is updated, then the cached thumbnail is generated—always in that order. Not that a backup program restored a newer cached thumbnail than the image...)
- 107,579
- 20
- 231
- 279
$HOME/.cache should not contain valuable data. Instead of deleting these, simply add CACHEDIR.TAG or .nobackup (see also Are CACHEDIR.TAG and .nobackup evaluated differently?) or add it to the exclude list.
If you restore the cache, you save little time for recreation. On the other hand you have to invest this time during the backup. If you delete the cache, you get rid of old and probably broken files.
In the end it makes sense to delete these and if there are special reasons why the cache is worth to restore, there may be better ways to go. For example a proxy, if you have a slow network and fear to loose the browser cache.
- 3,898
- 4
- 34
- 55