in reply to Emulate CGI "server push" to show real time status of CGI script for all browsers

Most browsers support the HTTP refresh, and for those that don't you can put a "Next" link at the bottom. Your whole page will reload for each update, and the script will run once for each update, but it's possible to support a wide range of browsers this way. It does place an extra burden on the script, which has to be able to pick up where it left off each time the browser reloads the page, but this is doable. The other option is to use scripts or plugins to communicate with the server and get information from a server process; this will allow for smoother updates but will support fewer browsers.


$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
  • Comment on Re: Emulate CGI "server push" to show real time status of CGI script for all browsers
  • Download Code

Replies are listed 'Best First'.
Re: Re: Emulate CGI "server push" to show real time status of CGI script for all browsers
by Anonymous Monk on Oct 01, 2003 at 00:05 UTC
    I second the suggestion of using HTTP refresh. It was the only way I found to reliably update data on various browsers (IE being particularly crappy about server-push).

    My strategy is to spawn a background process that does the time-consuming work while redirecting the browser to a progress page. The background process periodically writes to the progress page. You can even change the refresh time in the meta tag on the progress page if you have an idea of how long you expect different steps in the processing to take.

    A tip I can pass along about doing this, when forking off a child process in a cgi script, make sure to close STDOUT and STDERR in the child or the browser will wait for the child to complete.

      I did exactly this for my CGIBurn application. Source code is there if you'd like to poach ideas; the code itself is GPL'd.
      IE being particularly crappy about server-push.

      IE does not support Server-Push.