Caching With Apache's mod_cache On Debian Etch
Caching With Apache's mod_cache On Debian EtchVersion 1.0 This article explains how you can cache your web site contents with Apache's mod_cache on Debian Etch. If you have a high-traffic dynamic web site that generates lots of database queries on each request, you can decrease the server load dramatically by caching your content for a few minutes or more (that depends on how often you update your content). I do not issue any guarantee that this will work for you!
1 Preliminary NoteI'm assuming that you have a working Apache2 setup (Apache 2.2.x - prior to that version, mod_cache is considered experimental) from the Debian repositories - the Apache version in the Debian Etch repositories is 2.2.3 so you should be good to go. I'm using the document root /var/www here for my test vhost - you must adjust this if your document root differs.
2 Enabling mod_cachemod_cache has two submodules that manage the cache storage, mod_disk_cache (for storing contents on the hard drive) and mod_mem_cache (for storing contents in memory which is faster than disk caching). Decide which one you want to use and continue either with chapter 2.1 (mod_disk_cache) or 2.2 (mod_mem_cache).
2.1 mod_disk_cacheThe mod_disk_cache configuration is stored in /etc/apache2/mods-available/disk_cache.conf, so let's edit that one: vi /etc/apache2/mods-available/disk_cache.conf Make sure you uncomment the CacheEnable disk / line, so that the minimal configuration looks as follows:
You can find explanations for these configuration options and further configuration options on http://httpd.apache.org/docs/2.2/mod/mod_disk_cache.html. Now we can enable mod_cache and mod_disk_cache: a2enmod cache /etc/init.d/apache2 force-reload 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: 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 man htcacheclean Of course, you don't want to start htcacheclean manually each time you reboot the server - therefore we edit /etc/rc.local... vi /etc/rc.local ... and add the following line to it, right before the exit 0 line:
This will start htcacheclean automatically each time you start the server.
|



Recent comments
1 day 3 hours ago
1 day 9 hours ago
1 day 13 hours ago
1 day 15 hours ago
1 day 23 hours ago
2 days 9 hours ago
2 days 10 hours ago
2 days 13 hours ago
2 days 18 hours ago
2 days 18 hours ago