Telling a browser to keep a connection alive
Tom Legrady
legrady-bJEeYj9oJeDQT0dZR+AlfA at public.gmane.org
Mon Jan 2 17:44:55 UTC 2006
Hi Madison
Are you sure a web browser is the best way to run this script? Or
maybe you need to re-structure things slightly to make it better fit
the web paradigm?
The reason I say this is that the web is intrinsically an interactive
medium, maybe static, maybe dynamic, but always immediate response,
for some definition of 'immediate'. Read Jakob Nielsen's excellent
essay "Response Times: The Three Important Limits" at http://
www.useit.com/papers/responsetime.html for a discussion of people's
reactions to various response rates.
I would suggest that if you need to run a script which takes more
than 30 seconds to run, there might be a better solution than
invoking it as an ordinary CGI:
* If the event can be scheduled, invoke it as a cron job; the
summary can be sent out as an email or be available on a web page.
* If the event cannot be scheduled, because it depends on the user
in some way, let it be invoked as a CGI, but then return a page
saying the job is running. You can then send off an email when the
job is done, with a report on the completed work, or with a URL to a
reporting CGI that examines the appropriate log file, using an ID
code passed to it. If the report really needs to be interactive, you
might consider an AJAX script for the reply page. Javascript on the
page can invoke a reporting CGI script, passing it an ID, and get
back the most recent entries from the log file. The reply page could
simply display raw log entries, or summarize them: "Examining files
to back up: 137 files to backup, 53% examined."; and later on,
"Backing up files: 17 of 237 files; 146 of 913 MB", and later still,
"Verifying files: 76% complete". Better still if the reports can
provide an estimate of time remaining for each phase. But I wonder
whether someone would really want to sit an watch such a report
accumulate gradually. Not my, I want to go do other fun stuff, if
nothing else, check to see if there's a new Jakob Nielsen or Paul
graham or Robert Cringley column to read. I suspect people might go
the interactive route the first couple of times, to be sure things
are working the way they want, but after that they'll settle for the
summary email at the end.
Tom Legrady
On 2-Jan-06, at 1:41 AM, Madison Kelly wrote:
> Does anyone know of a way to tell a web browser to not kill a
> connection (to a cgi script) that takes a certain period of time to
> respond?
>
> The reason I ask is that my perl program tries to spit out data
> to the browser every 30 seconds during a big job to keep the
> connection alive (I turn off buffering) but sometimes an external
> program I call holds things up for too long and the connection dies
> anyway.
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list