NYCPHP Meetup

[nycphp-talk] flush usage

Chris Shiflett shiflett at php.net
Thu Feb 13 14:10:47 EST 2003


--- Carlos Hoyos <cahoyos at us.ibm.com> wrote:
> I have a page that deals with a lengthy process, so I'm using flush to
> "push" the content as it's processed and give the user a feeling of page
> "in process"

There are many different reasons why this might not be working, and most
involve buffering somewhere (you mention mod_gzip, so I assume you are aware of
some of these issues). I wrote this simple script a good while ago to play
around with flush:

------------------------------
<p><b>Here is an example of a time-delayed list:</b></p>
<ul>

<?
flush();
sleep(3);
echo "<li>List item one</li>";
flush();
sleep(1);
echo "<li>List item two</li>";
flush();
sleep(1);
echo "<li>List item three</li>";
flush();
sleep(1);
echo "<li>List item four</li>";
flush();
sleep(1);
echo "<li>List item five</li>";
flush();
sleep(1);
?>

</ul>
------------------------------

You can try that simple test first and see if it helps.

I have also heard that IE won't display content as it is received unless the
first chunk is greater than ? bytes. Of course, testing with multiple browsers
as you are should eliminate these types of anomalies.

To really verify that your server is sending the proper HTTP message to allow
for the effect you seek, you can view the HTTP response by telnetting to your
Web server and issuing a request manually. Something like this:

GET /path/to/script.php HTTP/1.1
Host: example.org

You should see a Transfer-Encoding: chunked header in the response, and there
should be no Content-Length header.

Hope that helps.

Chris



More information about the talk mailing list