<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>

Attribute Description Default
metadata
string, optional

Name of the struct variable

cachedirectory
string, optional

Absolute path of cache directory (alias for directory).

throwonerror
boolean, optional

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

timespan
timespan, optional

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.

directory
string, optional

Absolute path of cache directory.

idletime
timespan, optional

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)#".

cachename
string, optional

definition of the cache used by name, when not set the "default Object Cache" defined in Lucee Administrator is used instead.

password
string, optional

When required for basic authentication, a valid password.

protocol
string, optional

Specifies the protocol used to create pages from cache. Either http:// or https://. The default is http://.

name
string, optional

name of return variable, valid with action="get"

id
any, optional

Id of the cached object

key
string, optional

key to access cache

port
number, optional

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.

timeout
any, optional

This attribute has been deprecated and is non-functional.

value
any, optional

For action="set", object which needs to be stored

action
string, optional
  • 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)

cache

expireurl
string, optional

A URL reference. Can include wildcards, for example: "*/view.cfm?id=*". Lucee flushes, from the cache, pages that match the specified URL or pattern.

username
string, optional

When required for basic authentication, a valid username.

<cfcache
    [metadata=string]
    [cachedirectory=string]
    [throwonerror=boolean]
    [timespan=timespan]
    [directory=string]
    [idletime=timespan]
    [cachename=string]
    [password=string]
    [protocol=string]
    [name=string]
    [id=any]
    [key=string]
    [port=number]
    [timeout=any]
    [value=any]
    [action=cache|flush|clientcache|servercache|optimal|content|put|get]
    [expireurl=string]
    [username=string]
><!--- body --->[</cfcache>]

Examples

There are currently no examples for this tag.

See also