From John.Hockaday at ga.gov.au Thu Jun 23 23:58:49 2005
From: John.Hockaday at ga.gov.au (John.Hockaday@ga.gov.au)
Date: Fri, 24 Jun 2005 16:58:49 +1000
Subject: [Canberra-pm] Writing output to a web browser like clearing a buffer
Message-ID: <158ADDBA43E6C748BBD230A469EC6A4D9984CE@mail.ga.gov.au>
Hi All,
I'm using the PERL CGI module to generate output from a submitted web form.
The content of the web page is very lengthy. It also takes a while for the
PERL script to run because it is doing a lot of processing to get the output.
I have tried emptying the buffer with the "$| = 1;" command. If I run the
script on the command line the output prints without buffering and is OK. If
I run the script from my apache web browser the header prints but then
nothing prints until the whole script is processed. I expect that users will
think that the process is not running and stop it or worse still try to run
it again.
Is there a way that I can clear the buffer to print to the browser without
having to wait for the whole page to be generated? I tried CGI "push" and
"-nph" options but these just gave me a "malformed header" error in by apache
error log file.
Thanks in advance for any help.
John Hockaday
Geoscience Australia
GPO Box 378
Canberra ACT 2601
(02) 6249 9735
http://www.ga.gov.au/
john.hockaday\@ga.gov.au
From jarich at perltraining.com.au Fri Jun 24 01:22:35 2005
From: jarich at perltraining.com.au (Jacinta Richardson)
Date: Fri, 24 Jun 2005 18:22:35 +1000
Subject: [Canberra-pm] [Fwd: Re: Writing output to a web browser like
clearing a buffer]
Message-ID: <42BBC2CB.7060208@perltraining.com.au>
Sorry, I forgot to send this to all just in case someone else might disagree or
alternately find it useful...
-------- Original Message --------
Subject: Re: [Canberra-pm] Writing output to a web browser like clearing a buffer
Date: Fri, 24 Jun 2005 17:17:57 +1000
From: Jacinta Richardson
Organization: Perl Training Australia Pty Ltd
To: John.Hockaday at ga.gov.au
References: <158ADDBA43E6C748BBD230A469EC6A4D9984CE at mail.ga.gov.au>
John.Hockaday at ga.gov.au wrote:
> Is there a way that I can clear the buffer to print to the browser without
> having to wait for the whole page to be generated?
Have you checked to make certain that the problem is with the CGI script and not
with the browser? If your content is embedded in a great many tables which
exist purely for layout purposes, then you may find that your browser is caching
the response until it has sufficient information to render everything correctly
and only then giving you your output. (This is why CSS is a better alternative)
If this might be the cause, strip off all the formatting information outside of
your data and see if things improve.
If that doesn't help, try using something like wget to grab the page and output
it to a file. Follow the file creation with a tail -f and see whether all the
data comes in one big lot, or continuously.
If your data is simple, but involves one huge table of information, see whether
you can improve matters by telling the browser how big the table will be and how
wide the columns are. Use colgroup tags and percentage widths to achive this.
If this doesn't work, see if it is possible to break the table up into smaller
sections. Careful use of colgroup information on your tables can make it
possible to have many separate tables still look like one big one. Both of
these methods mean that your user can look at the first part of the table while
the other rows render.
If it definately *is* the CGI program (which sounds unlikely as it should run
almost as fast through the server as on the command line) then we can all have
fun trying to optimise it. :)
All the best,
Jacinta
--
("`-''-/").___..--''"`-._ | Jacinta Richardson |
`6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia |
(_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 |
_..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au |
(il),-'' (li),' ((!.-' | www.perltraining.com.au |
--
("`-''-/").___..--''"`-._ | Jacinta Richardson |
`6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia |
(_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 |
_..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au |
(il),-'' (li),' ((!.-' | www.perltraining.com.au |
From pa_bryan at yahoo.co.uk Fri Jun 24 02:44:22 2005
From: pa_bryan at yahoo.co.uk (pa_bryan@yahoo.co.uk)
Date: Fri, 24 Jun 2005 19:44:22 +1000
Subject: [Canberra-pm] Writing output to a web browser like clearing a
buffer
In-Reply-To: <158ADDBA43E6C748BBD230A469EC6A4D9984CE@mail.ga.gov.au>
References: <158ADDBA43E6C748BBD230A469EC6A4D9984CE@mail.ga.gov.au>
Message-ID: <20050624094422.GB4005@pabryan.mine.nu>
On Fri, Jun 24, 2005 at 04:58:49PM +1000, John.Hockaday at ga.gov.au wrote:
> Hi All,
>
> I'm using the PERL CGI module to generate output from a submitted web form.
> The content of the web page is very lengthy. It also takes a while for the
> PERL script to run because it is doing a lot of processing to get the output.
> I have tried emptying the buffer with the "$| = 1;" command. If I run the
> script on the command line the output prints without buffering and is OK. If
> I run the script from my apache web browser the header prints but then
> nothing prints until the whole script is processed. I expect that users will
> think that the process is not running and stop it or worse still try to run
> it again.
>
> Is there a way that I can clear the buffer to print to the browser without
> having to wait for the whole page to be generated? I tried CGI "push" and
> "-nph" options but these just gave me a "malformed header" error in by apache
> error log file.
$| = 1 turns off output buffering. Maybe it's as simple as that?
Cheers,
Paul.
From John.Hockaday at ga.gov.au Sun Jun 26 17:40:18 2005
From: John.Hockaday at ga.gov.au (John.Hockaday@ga.gov.au)
Date: Mon, 27 Jun 2005 10:40:18 +1000
Subject: [Canberra-pm] [Fwd: Re: Writing output to a web browser like
clearing a buffer]
Message-ID: <158ADDBA43E6C748BBD230A469EC6A4D0F0085@mail.ga.gov.au>
Fist of all thanks to Jacinta and Paul for responding to my email.
Paul,
I had already tried setting $| =1; and that didn't fix the problem but it's
good to see that we were thinking along the same lines.
Jacinta,
You were right! The output worked fine with Mozilla Firefox so the problem
was with Internet Explorer. Although the output from the Perl script that I
was calling was wrapped in

tags the virtual includes in the standard
header and footer called tables to structure the navigation bars. I'll have
to work out how to present that same format with widths and colgroups and yet
still meet our organisation's header and footer requirements.
Thanks for the tip.
John
> -----Original Message-----
> From: canberra-pm-bounces at pm.org
> [mailto:canberra-pm-bounces at pm.org] On Behalf Of Jacinta Richardson
> Sent: Friday, 24 June 2005 6:23 PM
> To: canberra-pm at pm.org
> Subject: [Canberra-pm] [Fwd: Re: Writing output to a web
> browser like clearing a buffer]
>
>
> Sorry, I forgot to send this to all just in case someone else
> might disagree or
> alternately find it useful...
>
> -------- Original Message --------
> Subject: Re: [Canberra-pm] Writing output to a web browser
> like clearing a buffer
> Date: Fri, 24 Jun 2005 17:17:57 +1000
> From: Jacinta Richardson
> Organization: Perl Training Australia Pty Ltd
> To: John.Hockaday at ga.gov.au
> References: <158ADDBA43E6C748BBD230A469EC6A4D9984CE at mail.ga.gov.au>
>
> John.Hockaday at ga.gov.au wrote:
>
> > Is there a way that I can clear the buffer to print to the
> browser without
> > having to wait for the whole page to be generated?
>
> Have you checked to make certain that the problem is with the
> CGI script and not
> with the browser? If your content is embedded in a great
> many tables which
> exist purely for layout purposes, then you may find that your
> browser is caching
> the response until it has sufficient information to render
> everything correctly
> and only then giving you your output. (This is why CSS is a
> better alternative)
>
> If this might be the cause, strip off all the formatting
> information outside of
> your data and see if things improve.
>
> If that doesn't help, try using something like wget to grab
> the page and output
> it to a file. Follow the file creation with a tail -f and
> see whether all the
> data comes in one big lot, or continuously.
>
> If your data is simple, but involves one huge table of
> information, see whether
> you can improve matters by telling the browser how big the
> table will be and how
> wide the columns are. Use colgroup tags and percentage
> widths to achive this.
> If this doesn't work, see if it is possible to break the
> table up into smaller
> sections. Careful use of colgroup information on your tables
> can make it
> possible to have many separate tables still look like one big
> one. Both of
> these methods mean that your user can look at the first part
> of the table while
> the other rows render.
>
> If it definately *is* the CGI program (which sounds unlikely
> as it should run
> almost as fast through the server as on the command line)
> then we can all have
> fun trying to optimise it. :)
>
> All the best,
>
> Jacinta
>
> --
> ("`-''-/").___..--''"`-._ | Jacinta Richardson |
> `6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia |
> (_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 |
> _..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au |
> (il),-'' (li),' ((!.-' | www.perltraining.com.au |
>
>
>
>
> --
> ("`-''-/").___..--''"`-._ | Jacinta Richardson |
> `6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia |
> (_Y_.)' ._ ) `._ `. ``-..-' | +61 3 9354 6001 |
> _..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au |
> (il),-'' (li),' ((!.-' | www.perltraining.com.au |
>
>
> _______________________________________________
> Canberra-pm mailing list
> Canberra-pm at pm.org
> http://mail.pm.org/mailman/listinfo/canberra-pm
>