Improving Perceived Response Time


After each application page, the database, and the server environment have been tuned, a page takes as long to respond as the operations it executes. Some of those operations, such as long-running database queries, require that users wait for a response. Studies indicate that the acceptable response time for users is 8 seconds. This means that users wait an average of 8 seconds without a noticeable response before they go elsewhere or click the Refresh button.

The <CFFLUSH> tag can help accelerate users' perceived response time. With this tag, you can flush incremental output to browsers so that users have a visual indication that their request is successful and will be completed soon.

CAUTION

Before ColdFusion can flush data, it must compile the data to return. A long-running query must complete before data can be flushed. Some queries might be too long for the <cfflush> tag to help with perception of performance. In those cases, it's best to give users a "please wait" dialog or message to let them know you're processing their request.


The <cfflush> tag takes one optional attribute, INTERVAL, which is the number of bytes to collect and flush to a browser at one time. You should use INTERVAL only when a large amount of output will be sent to the client; it is used like this:

 <cfflush interval="integer number of bytes"> 

interval data will be flushed automatically whenever the specified number of bytes is in the output buffer (additional <cfflush> tags are not required).

TIP

You shouldn't use interval when generating complete HTML pages. Doing so could cause partial data to be flushedincomplete DHTML, for example. If the user were to activate that partial code, browser errors could be thrown. You should use interval only when outputting raw data, such as CSV content or XML.


Using <cfflush>

You should use <cfflush> when you think you can incrementally flush large amounts of data back to the user and help with perceived response time.

Because an HTML header is the first component to be flushed, errors occur if any subsequent tags change the header information. Tags that can alter the HTML header include the following:

  • <cfcontent>

  • <cfcookie>

  • <cfform>

  • <cfheader>

  • <cfhtmlhead>

  • <cflocation>

All these errors, except for <cfcookie>, can be caught and handled with the <cfcatch type="template"> tag. Cookie errors can be caught with <CFCATCH type="any">.



Macromedia ColdFusion MX 7 Certified Developer Study Guide
Macromedia ColdFusion MX 7 Certified Developer Study Guide
ISBN: 0321330110
EAN: 2147483647
Year: 2004
Pages: 389
Authors: Ben Forta

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net