Cache Template in Request Setting Explained
By Pete Freitag
One of the new features added to ColdFusion 9 is the Cache Template in Request setting located on the Server Settings > Caching page of the ColdFusion Administrator. The setting was recently featured in the ColdFusion 9 Performance Brief showing a 50x boost when enabled. This has lead to a lot of questions, and confusion on how it actually works, and what it does.
The Cache Template in Request setting works similar to the Trusted Cache setting, but the cache is flushed at the end of the request. The setting is enabled by default in ColdFusion 9.
When this setting is turned off the file timestamps must be checked every time you create a new instance of a CFC, cfinclude a template, or invoke a custom tag during the life of the request.
When the setting is enabled, and trusted cache is off the file timestamps are only checked on the first invocation of the component or template during the life of the request. This can lead to a signification performance boost in most cases, but the actual amount depends highly on how your code is written.
If you are already using trusted cache, you won't actually see any performance improvement due to this setting. That being said there should be no reason to uncheck this setting if you have trusted cache turned on.
There are some cases where this setting can cause a problem, though they are not very common. If you modify the contents of a template or CFC during the course of the request then the changes will not be picked up on subsequent calls. For example here's a bug report for ModelGlue (ticket 389) where the setting causes a problem with event generation.
Thanks to Adobe Engineer Rupesh Kumar for the confirmation, and to Ray Camden for helping to explore the issue. For more on caching settings in ColdFusion 9 see Mike Brunt's blog (link no longer works, was: www.cfwhisperer.com/post.cfm/caching-with-coldfusion-to-improve-performance).
Cache Template in Request Setting Explained was first published on February 25, 2010.
If you like reading about coldfusion, caching, performance, or cf9 then you might also like:
- ColdFusion 9 Performance Brief from Adobe
- OutOfMemoryError - GC overhead limit exceeded
- How CFThread Can Help OR Hurt Performance
- CFThread - Don't Abuse It
The FuseGuard Web Application Firewall for ColdFusion & CFML is a high performance, customizable engine that blocks various attacks against your ColdFusion applications.