Flushes currently available data to the client.
Data output tags, Page processing tags
<cfflush interval = "integer number of bytes">
attributeCollectionattribute whose value is a structure. Specify the structure name in the
attributeCollectionattribute and use the tag’s attribute names as structure keys.
Integer. Flushes output each time this number of bytes becomes available. HTML headers, and data that is already available when the tag is executed, are omitted from the count.
occurrence of this tag on a page sends back the HTML headers and
any other available HTML. Subsequent
on the page send only the output that was generated after the previous
When you flush data, ensure that enough information
is available, as some browsers might not respond if you flush only
a small amount. Similarly, set the
for a few hundred bytes or more, but not thousands of bytes.
interval attribute only when a large amount
of output is sent to the client, such as in a
cfoutput of a large query. Using this form globally
(such as in the Application.cfm file) might cause unexpected errors when
CFML tags that modify HTML headers are executed.
cfflush tag sends data to the browser when
it executes, it has several limitations, including the following:
Using any of the following tags or functions on a page anywhere
cfflush tag can cause errors or unexpected
SetLocale. Similarly, do not use any tags that
use AJAX features, including
or HTML format
tags. All of the preceding tags and functions normally modify the
HTML header, but cannot do so after a
cfflush sends the header.
cfset tag to set a cookie anywhere
on a page that has a
cfflush tag does not set the
cookie in the browser.
cfflush tag in the body of several
and custom tags, causes errors.
If you save Client variables as cookies, any client variables
that you set after a
cfflush tag are not saved
in the browser.
cferrortag discards the current output buffer and replaces it with the contents of the error page. The
cfflushtag discards the current buffer. As a result, the
Error.GeneratedContentvariable resulting from a
cferrortag after a
cfflushcontains any contents of the output buffer that has not been flushed. This content is not sent to the client. The content of the error page displays to the client after the bytes that have been sent.
following example uses
cfloop tags and the
number generating function to delay data display. It simulates a
page that is slow to generate data.
<h1>Your Magic numbers</h1> <p>It will take us a little while to calculate your ten magic numbers. It takes a lot of work to find numbers that truly fit your personality. So relax for a minute or so while we do the hard work for you.</p> <H2>We are sure you will agree it was worth the short wait!</H2> <cfflush> <cfflush interval=10> <!--- Delay Loop to make it seem harder. ---> <cfloop index="randomindex" from="1" to="200000" step="1"> <cfset random=rand()> </cfloop> <!--- Now slowly output 10 random numbers. ---> <cfloop index="Myindex" from="1" to="10" step="1"> <cfloop index="randomindex" from="1" to="100000" step="1"> <cfset random=rand()> </cfloop> <cfoutput> Magic number #Myindex# is: #RandRange 100000, 999999)#<br><br> </cfoutput> </cfloop>