Stores a copy of a page on the server and/or client computer,
to improve page rendering performance. To do this, the tag
creates temporary files that contain the static HTML returned
from a CFML page.

Use this tag if it is not necessary to get dynamic content each
time a user accesses a page.
You can use this tag for simple URLs and for URLs that contain
URL parameters.



Attribute Reference for the cfcache tag


Required: No
* cache: server-side and client-side caching.
* flush: refresh cached page(s).
* clientcache: browser-side caching only. To cache a personalized page, use this option.
* servercache: server-side caching only. Not recommended.
* optimal: same as "cache". Values:
  • cache
  • flush
  • clientcache
  • servercache
  • optimal
  • get
  • put


Required: No
Absolute path of cache directory.


Required: No
The interval until the page is flushed from the cache.


Required: No
Used with action = "flush". A URL reference. CFML
matches it against the mappings in the specified cache
directory. Can include wildcards. For example:


Required: No
A username


Required: No
A password


Required: No
Remote port to which to connect


Required: No
Protocol that is used to create URL from cache. Values:
  • http://
  • https://


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


Required: No
Name of the struct variable


Required: No
Default: NO
Reduces whitespace


Required: No
A Boolean value specifying whether to 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


Required: No
Id of the cached object


Required: No
key to access cache


Required: No
Default: YES
to use cache or not (if false it will process the content each time)


Required: No
Comma seperated list of all variables on which this cache would depend


Required: No
Flushes the cached item if it is not accessed for the specified time span.


Required: No
Cache directory


Required: No
name of return variable, valid with action="get"

Examples sample code using the cfcache tag

Adding a page to the cache

Puts HTML page into the cache and uses the cached version on subsequent calls to the page.

<cfcache action='optimal' directory='/path/to/directory' timespan='#createTimeSpan( 1, 0, 0, 0 )#' idletime='#createTimeSpan( 0, 12, 0, 0 )#'>
	<div id="some-id">Hello World!</div>

Expected Result: <div id="some-id">Hello World!</div>

Flushing a page from the cache

Flushes the 'hello-world.cfm' page from the cache.

<cfcache action='flush' directory='/path/to/directory' expireURL='/hello-world.cfm'></cfcache>

Fork me on GitHub