We have already shed some light on the question of web caching and its benefits in our «Web Caching: what is it?» article. We’ve also explained how web caching is realized in Helicon Ape in «How mod_cache works?» article. Back then mod_cache could only store requests in the memory, but now, after Helicon Ape 126.96.36.199 release, there’s mod_disk_cache module that enables cashing to the hard drive.
To make mod_disk_cache working one should perform the following simple steps:
- Create disk cache folder. Say,
- Grant Read & Write permisions for that folder to users running Application Pools on your IIS. By default it’s IIS_IUSRS group.
- Point to that folder in httpd.conf using
- Enable caching for requests to
/app/for example. To do that, specify in httpd.conf:
CacheEnable disk /app/
or in .htaccess inside /app/ folder:
That’s the minimum configuration needed to have something cached. Now all requests containing expiration time (e.g. Cache-Control header) will be cashed on disk.
mod_disk_cache saves cached requests into hierarchical folder structure inside CacheRoot. Length of names and levels of these folders are defined by
CacheDirLevels directives. Caching gives out even better effect when used together with mod_gzip module which compresses response before caching and sending it to the client.
Pros and cons of disk caching
The tests we’ve conducted showed that the speed of mem-based and disk-based cache is roughly equal.
The main advantage of disk cache is that cached data is stored on disk and does not depend on applications recycling, IIS and hardware reset, in contrast to memory cache that is stored until the first application recycling or IIS reset.
The shortage of disk cache lies in absense of intrenal recycling mechanism for the expired records that are not used any more. But that’s not that critical:) The workaround may be: configure sheduled recycling of all cache once a day, i.e. remove all subfolders (or aged records only) and their content from