<cfcache>
Speeds up page rendering when dynamic content does not have to be retrieved each time a user accesses a 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.
This tag may have a body.
This tag is also supported within <cfscript>
<cfcache
action=cache|flush|clientCache|serverCache|optimal|content|put|get
key=string
id=any
throwOnError=boolean
name=string
metadata=string
value=any
cacheName=string
username=string
password=string
protocol=string
timeSpan=timespan
idleTime=timespan
directory=string
cacheDirectory=string
timeout=any
expireURL=string
port=number
useQueryString=boolean
useCache=boolean
stripWhiteSpace=boolean
dependsOn=string
><!--- body --->[</cfcache>]
| Attribute | Description | Default |
|---|---|---|
action
string, optional
|
edit
|
cache |
key
string, optional
|
edit
key to access cache |
|
id
any, optional
|
edit
Id of the cached object |
|
throwOnError
boolean, optional
|
edit
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 |
|
name
string, optional
|
edit
name of return variable, valid with action="get" |
|
metadata
string, optional
|
edit
Name of the struct variable |
|
value
any, optional
|
edit
For action="set", object which needs to be stored |
|
cacheName
string, optional
|
edit
definition of the cache used by name, when not set the "default Object Cache" defined in Lucee Administrator is used instead. |
|
protocol
string, optional
|
edit
Specifies the protocol used to create pages from cache. Either http:// or https://. The default is http://. |
|
timeSpan
timespan, optional
|
edit
The interval until the item is flushed from the cache. A decimal number of days, for example:
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. |
|
idleTime
timespan, optional
|
edit
Flushes the cached item if it is not accessed for the specified time span: A decimal number of days, for example:
A return value from the CreateTimeSpan function, for example, "#CreateTimeSpan(0,6,0,0)#". |
|
directory
string, optional
|
edit
Absolute path of cache directory. |
|
cacheDirectory
string, optional
|
edit
Absolute path of cache directory (alias for directory). |
|
expireURL
string, optional
|
edit
A URL reference. Can include wildcards, for example: "/view.cfm?id=". Lucee flushes, from the cache, pages that match the specified URL or pattern. |
|
port
number, optional
|
edit
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. |
|
useQueryString
boolean, optional
|
edit
Whether to consider the query_string when caching, default is Introduced: 7.0.0.300 |
|
useCache
boolean, optional
|
edit
Whether to use the cache, default is Introduced: 7.0.0.300 |
|
stripWhiteSpace
boolean, optional
|
edit
Whether to strip stripWhiteSpace, default is Introduced: 7.0.0.300 |
Unimplemented Attribute(s)
| Attribute | Description | Default |
|---|---|---|
username
string,
optional
|
edit
When required for basic authentication, a valid username. * unimplemented * |
|
password
string,
optional
|
edit
When required for basic authentication, a valid password. * unimplemented * |
|
timeout
any,
optional
|
edit
This attribute has been deprecated and is non-functional. * deprecated * |
|
dependsOn
string,
optional
|
edit
A list of additional variables which invalidate the cache when changed. * unimplemented * |
Examples
editCache Example
<cfcache action='cache' timespan='#createTimeSpan( 0, 0, 0, 5 )#' idletime='#createTimeSpan( 0, 12, 0, 0 )#'>
<cfdump var="#now()#" />
</cfcache>
See also
- Cache
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)