Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Browser Timeout

by bastard (Hermit)
on Feb 22, 2001 at 21:14 UTC ( [id://60253]=note: print w/replies, xml ) Need Help??


in reply to Browser Timeout

Look into nph scripts. (non-parsed header) Basically you get to bypass the webserver (and it's output buffering) and talk directly to the browser via the cgi. The also permits real-time display output to be sent to the browser. We have used it for search engine indexing of sites before (indexes have taken as long as 10 minutes.)

I'm not totally sure of the details, but as long as you periodically return data the connection should be held open. IIRC you need a nph script to do this. Try returning a "." every so often. (This also lets the user know something is happening).

Look in the CGI.pm docs for the section titled "USING NPH SCRIPTS"
http://search.cpan.org/doc/LDS/CGI.pm-2.68/CGI.pm

Replies are listed 'Best First'.
NPH scripts? (was Re: Browser Timeout)
by eg (Friar) on Feb 22, 2001 at 23:54 UTC

    I'm curious because I've never used them, but what's the added advantage or utility of an NPH script over a non-NPH script. To bypass output buffer and avoid browser timeouts, I usually just set $&#124 and an alarm:

    { local $| = 1; local $SIG{ALRM} = sub { print `/usr/bin/fortune`; alarm ALARM_TIME; + }; alarm 1; ... process that (might) take a very long time ... alarm 0; }

    Would using NPH be better?

    update Thanks, merlyn.

    Thanks, ERic

      This works under modern Apache, but under older Apache versions, the script also had to be named nph-something to turn off the buffering. Consider the name as a signal that Apache should do its own $| = 1 equivalent.

      The other things that older Apache required was that these "NPH" scripts provide the first HTTP status line as well, since Apache essentially stepped out of the way entirely. I think this is still true for scripts named like this as a backward compatiblity.

      -- Randal L. Schwartz, Perl hacker

      I have the same question.... I have several scripts that take longer than my browser has patience. Where exactly do I PUT the ' $|=1; ' in order to make sure that I don't get timed out?
Re: Re: Browser Timeout
by Jonas (Beadle) on Feb 22, 2001 at 21:25 UTC
    Thanks guys, you've given me more than enough to work with... j

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://60253]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-23 18:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found