Tub 'o' Dogs

52. File-based caching in ColdFusion

I've extended Brandon Purcell's custom tag for in-memory caching so that cached content can be optionally stored in the file system, rather than in shared memory.

This update to the documentation explains the new functionality:

"File-based caching reduces the performance advantages of in-memory caching, but will still yield significant improvements in most cases (file IO is almost always cheaper than database access, for example) and exerts minimal impact on your application's memory requirements. CACHEDIR must be a ColdFusion-writeable directory and should be stored outside the web root if your cache contains sensitive content. It is recommended that STRIPWHITESPACE is set to 'true' when file-based caching is enabled, to minimise file IO. Note that the Application scope is still used to persist cache meta-data (scriptname and expiry).

CF_Accelerate will recreate a file-based cache automatically when the appropriate file is unavailable, making it possible to flush the cache by removing files from ATTRIBUTES.CACHEDIR. The usual methods of cache flushing - adding 'flushAccelerator=true' to the URL; through the CF_Accelerate Management Interface - are still available."

Version 1.4 of CF_Accelerate, which contains this update, can be downloaded here.