A cache is a temporary store for documents that allows them to be quickly retrieved and served repeatedly – The purpose is to prevent a situation where repeated requests for a web address URI causes the server to duplicate effort fetching and reassembling data from various sources.
MKDoc has an internal cacheing mechanism at the document level. Authors can state how long they intend information in a document to stay current – This method is now deprecated in favour of a site-wide policy for cacheing all data, not just documents.
Cache Policies
As an example, a cache policy might say that articles are unlikely to change rapidly and can therefore be cached for a long time, however a news headlines page may change all the time and needs as little cacheing as is practical.
The policy for an MKDoc site can be tweaked to suit any such situation, but a basic policy will suffice for all but the most high-traffic situations. The policy is defined in a MKDoc::Control_List file like this:
Feel free to download and customise this default policy for your particular installation.
Installation
Note that MKDoc::Apache_Cache is an all-purpose accelerator for any mod_perl appplication that uses Apache::Registry. These instructions are for the MKDoc CMS, but can easily be customised to suit other software.
You need to retrieve and install MKDoc::Apache_Cache from CPAN, this is a standard perl module and can be installed normally. You may find that additional modules are required depending on your system:
Apache
MKDoc::Control_List
Cache::Cache
Test::More
Compress-Zlib
Configuration
You now need to configure MKDoc to use the module and the policy.
Download the policy file and place in your MKDoc site directory. Make sure it is readable by the web-server user-account:
/var/www/mkdoc/example.com/cache-policy.txt
Open the httpd-mkdoc.conf file in an editor and locate this line:
PerlHandler Apache::Registry
Replace it with the following lines:
PerlSetEnv MKDoc_Apache_Cache_CONFIG /var/www/mkdoc/example.com/cache-policy.txt
PerlSetEnv MKDoc_Apache_Cache_CACHE_ROOT /var/www/mkdoc/example.com/cache
PerlSetEnv MKDoc_Apache_Cache_NAMESPACE apache_cache_gz
PerlHandler MKDoc::Apache_Cache
Adjust the paths as necessary to suit your installation. Restart apache and test your site.
You can check that the cache is in effect for any document by looking at the HTTP response headers, two new headers will be in place:
Etag: f298648cd5372b9616e5445dde5f34e2
Expires: Thu, 26 Aug 2004 20:49:47 GMT
These headers are hints for further downstream caches.
Additional information
You may be interested in following-up the concepts and rationale behind web-cacheing. Mark Nottingham's Caching Tutorial for Web Authors and Webmasters is a good place to start.