
278
Chapter 13: Designing and Optimizing a ColdFusion Application
•
The directory on the server in which to store the cached pages. The default directory is
cf_root
/
cache. It is a good practice to create a separate cache directory for each application. Doing so
can prevent the
cfcache
tag
flush
action from inappropriately flushing more than one
application’s caches at a time.
•
The time span indicating how long the page lasts in the cache from when it is stored until it is
automatically flushed.
You can also specify several attributes for accessing a cached page on the web server, including a
user name and password (if required by the web server), the port, and the protocol (HTTP or
HTTPS) to use to access the page.
Place the
cfcache
tag above any code on your page that generates output, typically at the top of
the page body. For example, the following tag tells ColdFusion to cache the page on both the
client and the server. On the server, the page is cached in the e:/temp/page_cache directory.
ColdFusion retains the cached page for one day.
<cfcache timespan="#CreateTimespan(1, 0, 0, 0)#" directory="e:/temp/
page_cache">
Caution:
If your Application.cfm page displays text; for example, if it includes a header page, use the
cfcache
tag on the Application.cfm page in addition to the pages that you cache. Otherwise,
ColdFusion displays the Application.cfm page output twice on each cached page.
Flushing cached pages
ColdFusion automatically flushes any cached page if you change the code on the page. It also
automatically flushes pages after the expiration timespan passes.
You can use the
cfcache
tag with the
action="flush"
attribute to immediately flush one or
more cached pages. You can optionally specify the directory that contains the cached pages to be
flushed and a URL pattern that identifies the pages to flush. If you do not specify a URL pattern,
all pages in the directory are flushed. The URL pattern can include asterisk (*) wildcards to
specify parts of the URL that can vary.
When you use the
cfcache
tag to flush cached pages, ColdFusion deletes the pages cached on the
server. If a flushed page is cached on the client system, it is deleted, and a new copy gets cached,
the next time the client tries to access the ColdFusion page.
The following example flushes all the pages in the e:/temp/page_cache/monthly directory that
start with HR:
<cfcache action="flush" directory="e:/temp/page_cache/monthly" expirURL="HR*">
If you have a ColdFusion page that updates data you use in cached pages, the page that does the
updating includes a
cfcache
tag that flushes all pages that use the data.
For more information on the
cfcache
tag, see
CFML Reference
.
Caching parts of ColdFusion pages
In some cases, your ColdFusion page might contain a combination of dynamic information that
ColdFusion must generate each time it displays the page, and parts it generates dynamically, but
that change less frequently. In this case, you cannot use the
cfcache
tag to cache the entire page.
Instead, use the
cfsavecontent
tag to cache the infrequently changed content.
Содержание ColdFusion MX
Страница 1: ...Developing ColdFusion MX Applications...
Страница 22: ...22 Contents...
Страница 38: ......
Страница 52: ...52 Chapter 2 Elements of CFML...
Страница 162: ......
Страница 218: ...218 Chapter 10 Writing and Calling User Defined Functions...
Страница 250: ...250 Chapter 11 Building and Using ColdFusion Components...
Страница 264: ...264 Chapter 12 Building Custom CFXAPI Tags...
Страница 266: ......
Страница 314: ...314 Chapter 14 Handling Errors...
Страница 344: ...344 Chapter 15 Using Persistent Data and Locking...
Страница 349: ...About user security 349...
Страница 357: ...Security scenarios 357...
Страница 370: ...370 Chapter 16 Securing Applications...
Страница 388: ...388 Chapter 17 Developing Globalized Applications...
Страница 408: ...408 Chapter 18 Debugging and Troubleshooting Applications...
Страница 410: ......
Страница 426: ...426 Chapter 19 Introduction to Databases and SQL...
Страница 476: ...476 Chapter 22 Using Query of Queries...
Страница 534: ...534 Chapter 24 Building a Search Interface...
Страница 556: ...556 Chapter 25 Using Verity Search Expressions...
Страница 558: ......
Страница 582: ...582 Chapter 26 Retrieving and Formatting Data...
Страница 668: ......
Страница 734: ...734 Chapter 32 Using Web Services...
Страница 760: ...760 Chapter 33 Integrating J2EE and Java Elements in CFML Applications...
Страница 786: ...786 Chapter 34 Integrating COM and CORBA Objects in CFML Applications...
Страница 788: ......
Страница 806: ...806 Chapter 35 Sending and Receiving E Mail...