vsailas has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I had this requirement, where I have a large page, which have multiple sections, the one template file that shows this page have calls to other template files. These templates get data from multiple queries to database.

Now my problem is that the showing of page is very slow, as it is printed in entirety ie, the page display is done only after all the backend queries are done with and results obtained.

is there a way so that I could split these different section of my page and show data one by one in the same browser window as they come, so that the viewer need not wait until the full page loads.

Can not use AJAX now, as it requires a lot of changes and have to find a way other than AJAX.
Any help or suggestions would be greatly appreciated.

Thank you.

Replies are listed 'Best First'.
Re: Multipart Display of cgi.
by pc88mxer (Vicar) on Apr 18, 2008 at 07:04 UTC

    How about using an IFRAME for each section? That will generate a new HTTP request for each part. It could get a little tricky if the queries have to be conducted sequentially, but I think it could still be made to work.

    If you must generate the page with only one HTTP response, then it depends. See the related discussion on How to stream output to html page?.

    Does your templating system support streaming its output, or does it only emit its output after the entire template has been processed? If the later, then there are these potential issues:

    1. You would have to explicitly process each sub-template and then emit its content before processing the next sub-template.
    2. You might have to break up the top-level template into "header" and "footer" sections and process those sections yourself.
    3. The resulting streamed HTML might not get incrementally rendered as you would like on all browsers. (See the comment made by akho.)