Template Cache Flushing Templates (CF 5.0)
Related Categories: ColdFusion
One of Macromedia's recommended best practices for ColdFusion (CF) performance is to enable Trusted Cache in Production. However, some sites say they can not do this because of daily Production changes. I believe it's common knowledge that all you need to do is push the new template, disable Trusted Cache, run the template, and re-enable trusted cache in order to update the template in the generated cache. I understand that this can be cumbersome when pushing multiple templates.
My colleague Tom Link created two templates for this issue. One template will flush the entire pCode cache for CF 4.5/5.0; the other will allow you specify individual templates to update in the trusted cache (also for CF 4.5/5.0). Both templates update the pCode cache without the need to restart the server or manually run the newly pushed code.
I recently had a customer who was using the code and found a bug where in certain conditions the template would set the Template Cache Size to 0 (zero). I've modified (and renamed) both templates, fixing that bug and adding enhancements -- including the ability to run both templates as custom tags or regular templates. The pcodeCacheFlush flushes the entire template cache; the trustedCacheFlush template has an option to flush the entire pcode cache or to allow you to update individual templates in the cache.
pcodeCacheFlush
Call in the browser, run as a scheduled task, or use as a custom tag. This tag flushes the entire pcode cache by setting Template Cache to zero (0), immediately caching a temporary file, then resetting Template Cache to the initial value. Control logging and output with URL parameters or tag attributes.
trustedCacheFlush
Call in the browser, run as a scheduled task, or use as a custom tag. This template has two mutually exclusive operations:
- Flush the entire pcode cache (default)
- Cache individual templates passed to it in a list.
trustedCacheFlush includes the operations of pcodeCacheFlush but will only operate if Trusted Cache is enabled. You can pass an optional parameter to have Trusted Cache enabled when the template completes.
pcodeCacheFlush | trustedCacheFlush



There are no comments for this entry.
[Add Comment] [Subscribe to Comments]