> I would like to send a page to the browser that will be displayed as a DB
> query is being processed/fetched and as soon as the query is completed the
> real page will be sent. Something similar to what expedia.com and orbitz
are
> doing as they fetch the results. Can this be done?
>
This is a general CGI question and not Perl specific, but htis a quiet list
so I'll answer anyway...

Use a content refresh header to keep refreshing your status page every few
seconds.  Your status page should check somewhere to see if the query has
completed and if so it should send a redirect to results page.

Suppose all query results are stored as temporary files on disk then the we
would do something like this:

- User submits query to query script.

- The query script generates a unique file name, schedules the query in the
background (passing the unique file name for results storage)  and redirects
the browser to the status page (passing the unique file name to watch for).

- The status page is set to reload every 5 seconds using a content meta tag.
Each time it reloads, the script checks if the result file exists.  If the
result file does exist the browser is redirected to the results page
(passing the unique file name to read).

- In the mean-time the query is performed in the background.  This could be
via a fork, `start` or Win32::Process::Create for example.  A better method
is to setup a search daemon on the server that allows jobs to be submitted
to a queue.  Either way, when the query is complete the results are saved to
the file name specified by the query script.

- The results page would read the content of the results file, format and
output the results and delete the result file.

Some engines use a cache mechanism to allow users to bookmark previous
result pages.  This is easily implemented: don't delete the result file
immediately, instead run a script every now then that deletes results older
then 'n' minutes, hours, days, etc.

You could get clever and store the query parameters too.  Each query would
be associated with a result file (perhaps using a tied hash to a dbm file).
In this way, if the same query re-executed the results will already be on
disk and the response will be immediate, saving server cycles.

--
  Simon Oliver


_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to