Re: how to implement
by Hero Zzyzzx (Curate) on May 16, 2001 at 23:48 UTC
|
put $|=1; at the top of your script. This will unbuffer output.
in case that's hard to read, it's "$|=1;" | [reply] [d/l] |
|
That doesn't seem to quite work. I wrote the follow test:
#!/usr/bin/perl
$|=1;
print "Content-type: text/html\n\n";
for (1..20) {
print "$_<br>\n";
sleep 2;
}
and the browser still waits until all 20 numbers are outputted before returning the page.
This is under IE 5.0, Perl 5.005 and Apache 1.3.19.
Update: If I increase the range to something higher, I find that around 40 or so, it's starts to output. Apache itself must be doing some buffering ...
| [reply] [d/l] |
|
The guilty party here is IE, not apache.
I just compared IE6 to N4.76, both on win2000.
IE won't display anything before it has read about
230 bytes. If you then reload the page, there's no
buffering.
quick fix:
print "<!-- hey IE, display this page already -->\n" x 5;
--
Brigitte 'I never met a chocolate I didnt like' Jellinek
http://www.horus.com/~bjelli/ http://perlwelt.horus.at | [reply] [d/l] |
|
| [reply] |
|
|
Re: how to implement "tail -f" using CGI
by saucepan (Scribe) on May 17, 2001 at 03:52 UTC
|
Try renaming your CGI script to nph-whatever.cgi. Many webservers will, upon noticing the "nph-" (no parsed headers) prefix on a CGI script, send the script output directly to the browser without any buffering.
| [reply] |
|
This is the "old fashioned" way to do it. Instead, you are
probably better off using the CGI.pm way, which is
documented as such:
use CGI qw [ -nph :standard ];
The '-nph' triggers a header equivalent to the aforementioned
'nph-' prefix on the CGI. There are several alternative methods,
plus other discussion, in the CGI documentation
under 'NPH'.
Of course, you will have to unbuffer STDOUT for full effect,
as with:
$|++;
As a further note, make sure the HTML you are sending to
the browser can be displayed immediately. Under Netscape,
for example, a table will not display until it is fully
loaded. If you keep sending table data ad infinitum, the
table will never display. This also applies to other tags
including, but not limited to, UL and OL.
| [reply] [d/l] [select] |
Re: how to implement "tail -f" using CGI
by Starky (Chaplain) on May 17, 2001 at 04:47 UTC
|
In the cheezy but effective category, if you are trying to create the visual impression of a continuously updated document but don't want the web server to have a bunch of processes loitering for extended periods of time sucking up system resources, you can use a meta tag like
<meta HTTP-EQUIV="REFRESH" CONTENT="15;URL=http://www.myurl.com/myapp?tail=mytail">
If the URL is self-referencing, then the page continuously updates itself every 15 seconds.
This strategy is used by the Big Brother monitoring tool, for example.
Hope this helps! | [reply] |
Re: how to implement
by Anonymous Monk on May 16, 2001 at 23:50 UTC
|
Reword it as "How to turn off the Buffering in the Browser"!
And the Solution should be clear. | [reply] |
Re: how to implement
by poomba (Initiate) on May 16, 2001 at 23:47 UTC
|
doh! original subject should have been "how to implement
"tail -f" using CGI". | [reply] |