SPUG: cgi help

dancerboy dancerboy at strangelight.com
Wed Apr 4 19:46:20 CDT 2001

At 4:51 PM -0700 4/4/01, Ryan Ames wrote:
>hello all,
>	I am writing a cgi script that is using oraperl to query the
>database and post the results.  My queries are somewhat on the hefty side
>and my browser keeps timing out.  Is there any way that I can keep this from
>happening?  thanks....

If the database query is taking that long, then instead of waiting 
for the query to finish, you should return a token that will allow 
the client to get a cached copy of the results after the query has 
completed.  E.g. (an extremely minimal example):


$token_id = some_random_number_guaranteed_to_be_unique();

print qq(
	Query in progress.  The results will be available
	<a href="$token_id.html">here</a>
	in approximate $n minutes.

close STDOUT;

$results = query_database();

open CACHE_FILE, ">$token_id.html";
print CACHE_FILE $results;


This is clunky and inelegant as shown here, but you can use this 
basic idea in conjunction with client-side and/or server-side 
scripting, frames, etc. to create a page that will give the user 
instant feedback on what's going on, and which will automatically 
update when the database query is finished.


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/

More information about the spug-list mailing list