3 things you probably did not know about cfcache

Written on 8 March 2011, 12:03am

Tagged with: ,

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.

  1. cfcache default action
    The default action of the cfcache tag changed from ColdFusion 8 to ColdFusion 9:

    • in ColdFusion 8, default action is cache (server-side and client-side caching)
    • in ColdFusion 9, default action is serverCache (server-side caching only)
  2. using cfcache to cache pages with URL parameters
    I found this one while reading the ColdFusion 9 book, volume 2.

  3. caching page fragments: ColdFusion stores the cfcache tag 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 cfcache tag is used to cache page fragments.

    If you have a cfcache tag in your code, your cache will contain one item.
    If you change the position of the cfcache tag (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.

Leave a response