Tags · Functions · Objects
Lucee Tag Reference
Choose a tag:

Tag <CFCACHE>

Speeds up page rendering when dynamic content does not have to be retrieved each time a user accesses the page. To accomplish this, cfcache creates temporary files that contain the static HTML returned from a page. You can use cfcache for simple URLs and URLs that contain URL parameters.

Body

This tag may have a body.

Example

	<cfcache
		[action="string"]
		[cachedirectory="string"]
		[cachename="string"]
		[directory="string"]
		[expireurl="string"]
		[id="any"]
		[idletime="timespan"]
		[key="string"]
		[metadata="string"]
		[name="string"]
		[password="string"]
		[port="number"]
		[protocol="string"]
		[throwonerror="boolean"]
		[timeout="any"]
		[timespan="timespan"]
		[username="string"]
		[value="any"]>

	[</cfcache>]
	
This tag is also supported within cfscript
	<cfscript>
		cache
		[action="string"]
		[cachedirectory="string"]
		[cachename="string"]
		[directory="string"]
		[expireurl="string"]
		[id="any"]
		[idletime="timespan"]
		[key="string"]
		[metadata="string"]
		[name="string"]
		[password="string"]
		[port="number"]
		[protocol="string"]
		[throwonerror="boolean"]
		[timeout="any"]
		[timespan="timespan"]
		[username="string"]
		[value="any"] {

	}
	</cfscript>

Attributes

The attributes for this tag are fixed. Except for the following attributes no other attributes are allowed.
Name Type Required Description
action string No - cache (default): server-side and client-side template caching.
- flush: refresh cached pages (template caching).
- clientcache: browser-side caching only. To cache a personalized page, use this option.
- servercache: server-side caching only. Not recommended.
- optimal: same as "cache".
- content: same as cache, but cache only the body of the tag, not the complete template (template caching).
- put: adds a key value pair to object cache (see function cachePut for more details)
- get: gets value matching given key from object cache (see function cacheGet for more details) 
cachedirectory string No Absolute path of cache directory (alias for directory). 
cachename string No definition of the cache used by name, when not set the "default Object Cache" defined in Lucee Administrator is used instead. 
directory string No Absolute path of cache directory. 
expireurl string No A URL reference. Can include wildcards, for example: "*/view.cfm?id=*". Lucee flushes, from the cache, pages that match the specified URL or pattern. 
id any No Id of the cached object 
idletime timespan No Flushes the cached item if it is not accessed for the specified time span:
A decimal number of days, for example: ".25", for one-fourth day (6 hours); "1", for one day; "1.5", for one and one half days
A return value from the CreateTimeSpan function, for example, "#CreateTimeSpan(0,6,0,0)#". 
key string No key to access cache 
metadata string No Name of the struct variable 
name string No name of return variable, valid with action="get" 
password string No When required for basic authentication, a valid password. 
port number No Port number of the web server from which the URL for the cached page is requested.
In the internal call from cfcache to cfhttp, Lucee resolves each URL variable in the page; this ensures that links in the page remain functional. 
protocol string No Specifies the protocol used to create pages from cache. Either http:// or https://. The default
is http://. 
throwonerror boolean No A Boolean value specifying whether t throw an error if the
flush
action encounters an error. Otherwise the action does not generate an error if it fails. If this attribute is
true
you can handle the error in a
cfcatch
block, for example, if a specified id value is invalid 
timeout any No This Attribute is deprecated 
timespan timespan No The interval until the item is flushed from the cache.
A decimal number of days, for example: ".25", for one-fourth day (6 hours); "1", for one day; "1.5", for one and one half days
A return value from the CreateTimeSpan function, for example, "#CreateTimeSpan(0,6,0,0)#".
The default action is to flush the item when it is idle for the time specified by the idleTime attribute, or cfcache action="flush" executes. 
username string No When required for basic authentication, a valid username. 
value any No For action="set", object which needs to be stored