Can I safely remove /var/cache?

From http://www.lindevdoc.org/wiki//var/cache

Sorry for the (very) late answer, but I believe it's important to include this bit for future reference.

Highlighted the bit which does answer this question.

The /var/cache directory contains cached files, i.e. files that were generated and can be re-generated any time, but they are worth storing to save time of recomputing them.

Any application can create a file or directory here. It is assumed that files stored here are not critical, so the system can delete the contents of /var/cache either periodically, or when its contents get too large.

Any application should take into account that the file stored here can disappear any time, and be ready to recompute its contents (with some time penalty).

So yes, you may remove these files without expecting anything bad to happen.


No.

For one, I believe that /var/cache/bind/ is the default directory where bind9 expects its zone files to be stored (at least on Debian; I don't know offhand if other distros follow suit)

For another, according to this documentation, pacman (the package manager used by Arch linux) stores its package cache under /var/cache/pacman/pkg/ and it most likely expects nothing but itself to modify the contents.

I recommend you read through the documentation more closely and decide whether this is a good time to clear the package cache.


As others have said, /var/cache/ can be used by any application to store information to save on retrieval time. In my experience though, most of the space taken up in there is from the system's package manager.

From the Arch Linux wiki:

pacman stores its downloaded packages in /var/cache/pacman/pkg/ and does not remove the old or uninstalled versions automatically, therefore it is necessary to deliberately clean up that folder periodically to prevent such folder to grow indefinitely in size.

pacman -Sc

However, unless storage space is a desperate issue, to save headache later from future incompatibility; one of these other tools should be utilized: paccache, pkgcacheclean, or pacleaner.


For other system:

Redhat based (Fedora, CentOS, SL, ...)

yum clean all
# or
dnf clean all

Debian based (Ubuntu, ...)

apt-get autoclean

SUSE based

zypper clean

Tags:

Cache