<CFCACHE ACTION="action" PROTOCOL="protocol name" TIMEOUT="timeout date-time" DIRECTORY="directory name" EXPIREURL="wildcarded URL reference">
CFCACHE allows you to speed up pages considerably in cases where the dynamic content doesn't need to be retrieved each time a user accesses the page. To accomplish this, it creates temporary files that contain the static HTML returned from a particular run of the ColdFusion page.
You can use CFCACHE for simple URLs and URLs that contain URL parameters.
Optional. Specifies one of the following:
Optional. Specifies the protocol used to create pages from cache. Specify either HTTP:// or HTTPS://. The default is HTTP://.
Optional. DateTime that specifies the oldest acceptable cached page. If the cached page is older than the specified datetime, ColdFusion refreshes the page. By default, ColdFusion uses all cached pages. For example, if you want a cached file to be no older than 4 hours, code the following:
<CFCACHE TIMEOUT="#DateAdd("h", "-4", Now() )#">
Optional. Used with ACTION=FLUSH. Specifies the fully qualified path of a directory containing the cfcache.map to be used when ACTION=FLUSH. The default is the directory of the current page.
Optional. Used with ACTION=FLUSH. EXPIREURL takes a wildcarded URL reference that ColdFusion matches against all mappings in the cfcache.map file. The default is to flush all mappings. For example, "foo.cfm" matches "foo.cfm"; "foo.cfm?*" matches "foo.cfm?x=5" and "foo.cfm?x=9".
In its simplest form, all you need to do is code <CFCACHE> at the top of a page to be cached:
In addition to the cached files themselves, CFCACHE uses a mapping file to control caching. This file is stored in the directory of the files being cached. It is named cfcache.map and uses a format similar to a Windows INI file. The mapping of a URL with parameters is stored as follows. Assume a directory "c:\InetPub\wwwroot\dir1" that has a CFM file called "foo.cfm", which can be invoked with or without URL parameters. The cfcache.map file entries for foo.cfm will look like this:
[foo.cfm] Mapping=C:\InetPub\wwwroot\dir1\CFCBD.tmp SourceTimeStamp=08/31/1998 08:59:04 AM [foo.cfm?x=5] Mapping=C:\InetPub\wwwroot\dir1\CFCBE.tmp SourceTimeStamp=08/31/1998 08:59:04 AM [foo.cfm?x=9] Mapping=C:\InetPub\wwwroot\dir1\CFCBF.tmp SourceTimeStamp=08/31/1998 08:59:04 AM
The cfcache.map file in a given directory stores mappings for that directory only. Any time the timestamp of the underlying page changes, ColdFusion updates the cache file for that URL only. ColdFusion uses the SourceTimeStamp field to determine if the currently cached file is up to date or needs to be rebuilt.
You can refresh the cache in the following ways:
Note the following regarding CFCACHE:
<CFSETTING SHOWDEBUGOUTPUT="NO">
.
PROTOCOL="https://"
.