Flush STDOUT

software development

#1

I have some pages that are slow to load. I’d like to return a message immediately for the user to wait, and then return the rest of the page once it is ready.

I’ve tried a number of techniques, including this (which worked on my old host):

$old_fh = select(STDOUT);
$| = 1;
select($old_fh);

Nothing is working. Please advise on how to get this to work. Thanks.

– Scott


#2

I have always thought the function flush was intended for this purpose, but I have never had to rely on it, so I’m not sure if it will help you or not.

Sorry I can’t provide a more complete response, but that’s what I know!


#3

Thx, but I should have specified, I’m doing this in PERL, not PHP. I tried your suggestion, but PERL doesn’t recognize “flush” on its own.

I have also tried:

$old_fh = select(STDOUT);
$| = 1;
IO::Handle::flush($old_fh);
STDOUT->flush();
select($old_fh);

Again with no luck.

I think it may be some kind of configuration issue?

– Scott


#4

Here’s something I found discussing this as a bug with Apache 2. I don’t quite follow it, other than it does appear to be an Apache bug…

http://mail-archives.apache.org/mod_mbox/httpd-bugs/200210.mbox/20021003195856.21676.qmail@nagoya.betaversion.org

– Scott


#5

Hmm, but of course DreamHost is not running Apache 2.

Problem need to look elsewhere for the bottleneck - server load, perhaps? A lot of libraries/modules? Have you tried putting the flush in a BEGIN block?

:cool: Perl / MySQL / HTML+CSS