We help IT Professionals succeed at work.

CGI takes too long

serg111
serg111 asked
on
#!/usr/bin/perl

OutputPage();
AnalizeResult();
exit;

This script above shows web page with delay 40 sec since function AnalizeResult() takes 40 sec to return. How can force page to be shown immediately after OutputPage() and then run AnalizeResult()?
Comment
Watch Question

Chris SFreelance cloud developer

Commented:
try

$|++;

use CGI;

$q = new CGI;

print $q->header;

OutputPage();
AnalizeResult();
exit;



BRONZE EXPERT

Commented:
.. doesn't help much when the sever times out before AnalizeResult() has completed.

You eithetr need to tell the web server's admin to increase the timeout (which s/he will not do, usually), or print a page which refreshes after a few seconds, while your CGI writes to a file.

Author

Commented:
It doesn't work for me too :-(
Timeout is now 60 sec , so no sence to increase

and when I refresh page like this:
print "Location: http://www.server.com/M_BANNER.GIF\n\n";
It still takes 40 sec for file to load
BRONZE EXPERT

Commented:
> .. It still takes 40 sec for file to load
hmm, bad designed page ;-)
Anyway, if it is an image it should be cached by the browser, so should not be read again after a reload.
Did you write your refresh in the META tags of the html HEADer ?
Commented:
If AnalizeResult() doesn't output any HTML and OutputPage() doesn't create any data that AnalizeResult() needs, then you could do AnalizeResult() in a background process so that the CGI can end as soon as OutputPage() is done:

#!/usr/bin/perl

if (fork)
{
   # parent
   OutputPage();
}
else
{
   # child
   AnalizeResult();
}

exit;

Explore More ContentExplore courses, solutions, and other research materials related to this topic.