User Guide

60 Chapter 2: ColdFusion Tags
Attributes
Usage
Use this tag in pages whose content is not updated frequently. Taking this action can greatly
improve the performance of your application.
The output of a cached page is stored in a file on the client browser and/or the ColdFusion server.
Instead of regenerating and redownloading the output of the page, each time it is requested,
ColdFusion uses the cached output. ColdFusion regenerates and downloads the page only when
the cache is flushed, as specified by the
timespan attribute, or by invoking cfcache
action=flush
.
To enable a simple form of caching, put a cfcache tag, specifying the timespan attribute, at the
top of a page. Each time the specified time span passes, ColdFusion flushes (deletes) the copy of
the page from the cache and caches a new copy for users to access.
Attribute Req/Opt Default Description
action Optional cache 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".
directory Optional cf_root/cache Absolute path of cache directory.
timespan Optional Page is
flushed only
when
cfcache
action =
"flush"
is
executed
The interval until the page 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)#"
expireURL Optional Flush all
cached pages
Used with action = "flush". A URL reference.
ColdFusion matches it against the mappings in the
specified cache directory. Can include wildcards. For
example:
"*/view.cfm?id=*".
username Optional A username. Provide this if the page requires
authentication at the web server level.
password Optional A password. Provide this if the page requires
authentication at the web server level.
port Optional The current
page port
Port number of the web server from which the URL is
requested. In the internal call from
cfcache to cfhttp,
ColdFusion resolves each URL variable in the page;
this ensures that links in the page remain functional.
protocol Optional The current
page protocol
Protocol that is used to create URL from cache.
http://
https://