Ask Ben: Simple Data Caching In ColdFusion

<cfoutput>
 
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html>
	<head>
		<title>Simple Data Caching Example in ColdFusion</title>
	</head>
	<body>
 
		<h1>
			Simple Data Caching Example in ColdFusion
		</h1>
 
		<p>
			Current Timestamp:
			#TimeFormat( Now(), "hh:mm:ss TT" )#
		</p>
 
		<!---
			This data will be cached using a timeout. This data
			will be persisted for 5 minutes.
		--->
		<cf_simplecache
			key="exampleA"
			timeout="#CreateTimeSpan( 0, 0, 5, 0 )#"
			cache="#APPLICATION.Cache#">
 
			<p>
				Cached Timestamp (Timeout):
				#TimeFormat( Now(), "hh:mm:ss TT" )#
			</p>
 
		</cf_simplecache>
 
 
		<!---
			This data will be cached using an explicit expiration
			date and will be persisted until February 1st.
		--->
		<cf_simplecache
			key="exampleB"
			expirationdate="02/01/2008"
			cache="#APPLICATION.Cache#">
 
			<p>
				Cached Timestamp (Expiration):
				#TimeFormat( Now(), "hh:mm:ss TT" )#
			</p>
 
		</cf_simplecache>
 
	</body>
	</html>
 
</cfoutput>

For Cut-and-Paste