Make sure you uncomment the CacheEnable disk / line, so that the minimal configuration looks as follows:
# If you enable disk caching, you need to use htcacheclean from the
# apache2-utils package to ensure that the cache does not grow indefinitely.
# See the htcacheclean man page for details.
# There is currently no mechanism in the Debian package to start htcacheclean
# automatically, but it is planned to add such a mechanism in the future.
CacheEnable disk /
Now we can enable mod_cache and mod_disk_cache:
sudo a2enmod cache
sudo a2enmod disk_cache
To make sure that our cache directory /var/cache/apache2/mod_disk_cache doesn't fill up over time, we have to clean it with the htcacheclean command. That command is part of the apache2-utils package which we install as follows:
sudo apt-get install apache2-utils
Afterwards, we can start htcacheclean as a daemon like this:
htcacheclean -d30 -n -t -p /var/cache/apache2/mod_disk_cache -l 100M -i
This will clean our cache directory every 30 minutes and make sure that it will not get bigger than 100MB. To learn more about htcacheclean, take a look at
Of course, you don't want to start htcacheclean manually each time you reboot the server - therefore we edit /etc/rc.local...
... and add the following line to it, right before the exit 0 line:
/usr/sbin/htcacheclean -d30 -n -t -p /var/cache/apache2/mod_disk_cache -l 100M -i
This will start htcacheclean automatically each time you start the server.