3 things you probably did not know about cfcache
Written on 8 March 2011, 12:03am
Note, February 17th 2014: this post was written on March 8th 2011, but I forgot to publish it. So here it is, almost 3 years later 🙂
I recently had to work with cfcache in ColdFusion 9 and I found a few interesting things. Two of them deal about the backwards compliance in ColdFusion 9, while the third is about caching page fragments.
- cfcache default action
The default action of the
cfcachetag changed from ColdFusion 8 to ColdFusion 9:
- using cfcache to cache pages with URL parameters
I found this one while reading the ColdFusion 9 book, volume 2.
- caching page fragments: ColdFusion stores the
cfcachetag line number as part of the ID for the cached item.
This one is a little bit more complicated and I found it on the Rob Brooks-Bilson‘s blog while reading about the second point above (caching pages with URL params).
It deals with the number of items in the ColdFusion cache when the
cfcachetag is used to cache page fragments.
If you have a
cfcachetag in your code, your cache will contain one item.
If you change the position of the
cfcachetag (you move it one line below), your cache will contain two items.
You can read the cache content using the getAllTemplateCacheIds() function.
The example in the link above is pretty suggestive.
Each page fragments gets its own entry in the cache since fragments can be independently expired or flushed from the cache. […] What’s happening is that ColdFusion is using the position of the code in your page as part of the ID for the cached item.
Written by Dorin Moise (Published articles: 243)