View comments | RSS feed

cfflush

Description

Flushes currently available data to the client.

Category

Data output tags, Page processing tags

Syntax

<cfflush
  interval = "integer number of bytes">

See also

cfcache, cfheader, cfinclude, cfsetting, cfsilent

Attributes

Attribute Req/Opt Default Description
interval
Optional

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.

Usage

The first occurrence of this tag on a page sends back the HTML headers and any other available HTML. Subsequent cfflush tags on the page send only the output that was generated after the previous flush.

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 interval attribute for a few hundred bytes or more, but not thousands of bytes.

Use the interval attribute only when a large amount of output will be sent to the client, such as in a cfloop or 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.

Caution:   Once you have used this tag on a page, any CFML function or tag on the page that modifies the HTML header causes an error. (These include: cfcontent, cfcookie, cfform, cfheader, cfhtmlhead, and cflocation.)

Using the cfset tag to set a cookie scope variable causes an error. Cookie errors can be caught with the cfcatch type = "Any" tag. Other errors can be caught with cfcatch type = "template".

Using the cfflush tag within a cfsavecontent tag (if the cfsavecontent tag has content) causes an error.

Note:   Normally, the cferror tag discards the current output buffer and replaces it with the contents of the error page. The cfflush tag discards the current buffer. As a result, the Error.GeneratedContent variable resulting from a cferror tag after a cfflush contains 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.

The following example uses cfloop tags and the rand random number generating function to delay data display. It simulates a page that is slow to generate data.

Example

<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 number #Myindex# is:&nbsp;&nbsp;#RandRange( 
100000, 999999)#<br><br>
  </cfoutput>
</cfloop>

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6

Comments are no longer accepted for ColdFusion MX. ColdFusion 8 is the current version.

Comments


No screen name said on Mar 17, 2005 at 11:54 PM :
Hi all!
I'd like to display this gif image before processing the file upload (there's a form wich sends the files to this page), but the image doesn't want to display!! arrrgh...

Can please someone tell me, why this does not work?

roger


<html>
<head>
<title>Upload Files</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="../../styles.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#DFDFDF">
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><p class="normal" align="center"><strong>File upload in process. Please wait.</strong></p>
<p align="center"><img src="../../images/busy.gif" border="0"></p>
</td>
</tr>
</table>
<cfflush>

<cfif #form.file1# NEQ "">
<cffile action="upload" filefield="file1" destination="#form.dir#" nameconflict="makeunique">
<cfset file1 = #file.serverfile#>
</cfif>

<cfif #form.file2# NEQ "">
<cffile action="upload" filefield="file2" destination="#form.dir#" nameconflict="makeunique">
<cfset file2 = #file.serverfile#>
</cfif>

<cfif #form.file3# NEQ "">
<cffile action="upload" filefield="file3" destination="#form.dir#" nameconflict="makeunique">
<cfset file3 = #file.serverfile#>
</cfif>

<cfif #form.file4# NEQ "">
<cffile action="upload" filefield="file4" destination="#form.dir#" nameconflict="makeunique">
<cfset file4 = #file.serverfile#>
</cfif>

<cfif #form.file5# NEQ "">
<cffile action="upload" filefield="file5" destination="#form.dir#" nameconflict="makeunique">
<cfset file5 = #file.serverfile#>
</cfif>

<script language="JavaScript">
window.opener.location.reload();
window.self.close();
</script>
</body>
</html>
jrunrandy said on Mar 24, 2005 at 12:09 PM :
I'm sorry to say that I don't know the answer to your question. You will get a better and quicker answer by posting questions like this to the online forums: http://webforums.macromedia.com/coldfusion.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6/CFML_Reference/Tags-pt138.htm