<CFCACHE> Tag - ColdFusion


>> Return to CF Tag List

This tag stores a copy of the current generated page on the server or client machine to improve the overall performance.

Syntax:
  <CFCACHE [ACTION="type of cache"]
                    [DIRECTORY="Absolute path of cache directory"]
                    [TIMESPAN="flush interval"]
                    [EXPIREURL="page path to flush"]
                    [USERNAME="user name"]
                    [PASSWORD="password"]
                    [PORT="current page port"]
                    [PROTOCOL="current protocol"]>

  <CFCACHE> Comments from Macromedia LiveDocsLiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-pa8.htm
to get rid of the comment cfcache puts at the begining, call another template first, use cfhttp to call the original, cached template, then use Replace() to remove the comment

<!--- call the main template, where we use cfcache to cache the response
<cfset theURL = 'http://localhost/main.cfm?' & '#CGI.QUERY_STRING#'>
<cfhttp url='#Variables.theURL#' method="GET">

<!--- remove the comment cfcache puts at the top of cached response, so the response will be XML compatible --->
<cfset theComment = '<!---' & '#Variables.theURL#' & '--->'>
<cfset xmlResponse = Replace('#cfhttp.fileContent#', '#theComment#', '' , "one")>

<!--- send a clean response to the client --->
<cfoutput>#Variables.xmlResponse#</cfoutput> --->

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-pa8.htm
CfCache adds an html comment on the first line of the page being cached (server side cached). However, the first line is reserved for the DOCTYPE declaration. With the comment generated by CF, it cancels out the basis of having a doctype declaration, and therefore does not allow standards based, css websites to be integrated with server caching.

In short, MSIE goes into quirks mode and ignores your CSS.

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-pa8.htm
This tag ignores cgi.path_info, making pages with parameters passed in a search engine friendly way such as index.cfm/blah1/blah2 unusable.

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-pa8.htm
We are working to improve the examples in the ColdFusion reference pages. We propose to replace the current example on this page with the the following example. If you have any comments on this example, add them to this page.

<!--- This example produces as many cached files as there are
URL parameter permutations. You can see that the page is cached when the timestamp doesn't change.--->
<cfcache
timespan="#createTimeSpan(0,0,10,0)#">
<body>

<h3>This is a test of some simple output</h3>

<cfoutput>
This page was generated at #now()#<br>
</cfoutput>

<cfparam name = "URL.x" default = "no URL parm passed" >
<cfoutput>The value of URL.x = # URL.x #</cfoutput>

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-pa8.htm
In response to the request to add a parameter to cfcache:

ColdFusion has the opposite problem to the one described.
ColdFusion always returns cfcached pages in UTF-8; that is, with an HTTP header specifying a charset of UTF-8.
We have submitted a bug against this behavior, number 54095, against this behavior.

I believe that the described problem is different, and not related to cfcache.
While Dreamweaver is saving the page as UTF-8 code, ColdFusion is reading the file using the system default encoding, probably Windows-1252 or ISO-8859-1.

To force ColdFusion to read the page as UTF, do either of the following:
In Dreamweaver, select the "Include Unicode Signature (BOM)" option on the Title/Encoding dialog.
OR
Use the following tag at the top of each CFML page that you save in UTF-8:
<cfprocessingdirective pageencoding="UTF-8">

If select to include the BOM in Dreamweaver you do not need to use the cfpageencoding tag on your pages, as ColdFusion will read the BOM (two bytes at the start of the file) and determine the page is UTF-8 automatically.

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-pa8.htm
Why is it not possible using cfcache to add a parameter

pageencoding="UTF-8"

to save a cached file in UTF-8 format? All files will be saved in "Western (Latin1)" format -- but the original file is UTF-8 encoded using Dreamweaver (CTRL+J > UTF-8). This is terrible, because all cached files will be shown in the wrong encoding, thus special characters are displayed wrong.

Is there a workaround for this bug??



[Top]


Recommended Books

[Top]

Web Sites

[Top]

Copyright © 2003- 2008, Orville Paul Chomer, All Rights Reserved