Cache-O-Matic
The easiest way to cache content in Mura is to use the built in cf_cacheOMatic tag. For those who are not familiar with the tag, it gives the user the ability to cache any desired display content.
<cf_CacheOMatic
key="{a unique key}"
nocache="{1=don't cache, 0=cache}"
timespan="{timespan object}">
Content here ...
</cf_CacheOMatic>
Example
<cf_CacheOMatic
key="page#$.content('contentID')#"
nocache="#$.event('noCache')#">
<cfoutput>
<p>The title of this page is #$.content('menuTitle')#.</p>
</cfoutput>
</cf_CacheOMatic>
You can also set the timespan the item will remain cached.
<cf_CacheOMatic
key="page#$.content('contentID')#"
nocache="#$.event('noCache')#"
timespan="#CreateTimeSpan(0,0,5,0)#">
<cfoutput>
<p>The title of this page is #$.content('menuTitle')#.</p>
</cfoutput>
</cf_CacheOMatic>
If you have a code snippet that you do not want to ever be cached you can set request.cacheItem=false and any wrapping CacheOMatic tags will not add the rendered output to the cache. (For example, $.setDynamicContent() uses request.cacheItem=false)
<cf_CacheOMatic
key="page#$.content('contentID')#"
nocache="#$.event('noCache')#">
<cfoutput>
<p>The username of the person logged in is #$.currentUser('username')#.</p>
<cfset request.cacheItem=false>
</cfoutput>
</cf_CacheOMatic>
Programmatically Setting the Cached Items Timespan
If you have a code snippet that you want to be in the sites cache for no longer that a certain timespan you can set request.cacheItemTimeSpan={TimeSpan Object}.
<cf_CacheOMatic
key="page#$.content('contentID')#"
nocache="#$.event('noCache')#">
<cfoutput>
<p>The title of this page is #$.content('menuTitle')#.</p>
<!--- cache for no longer than 5 minutes.--->
<cfset request.cacheItemTimeSpan=createTimeSpan(0,0,5,0)>
</cfoutput>
</cf_CacheOMatic>