[tbnl-devel] send-headers and slow page generation

Edi Weitz edi at agharta.de
Sun May 14 19:02:10 UTC 2006


On Sun, 14 May 2006 11:52:51 -0400, Yannick Gingras <ygingras at ygingras.net> wrote:

> I'd like to use TBNL for a web application that have a really slow
> page generation rate.  At first I thought that send-headers was the
> solution: write the page header and navigation before launching the
> slow content generation and then write the content as it is
> generated.  I made this small example (using cl-who):
>
> (defun test-page ()
>   (with-html-output (*standard-output* (send-headers) :prologue t :indent t)
>     (:html (:body (:p (sleep 3) (fmt "hi, i'm the ~dth loop" 0))
> 		  (:p (sleep 3) (fmt "hi, i'm the ~dth loop" 1))
> 		  (:p (sleep 3) (fmt "hi, i'm the ~dth loop" 2))
> 		  (finish-output *standard-output*)
> 		  (:p (sleep 3) (fmt "hi, i'm the ~dth loop" 3))
> 		  (:p (sleep 3) (fmt "hi, i'm the ~dth loop" 4))
> 		  (:p (sleep 3) (fmt "hi, i'm the ~dth loop" 5))))))
>
> Running it (without the call to send-headers) in my REPL have the
> desired result: each part is printer before the next call to sleep.
> On the other hand, when I try it live with TBNL I have to wait for
> the whole page to be generated.  Maybe is misinterpreted the
> documentation.  Is it possible to write partial pages to the client
> stream with TBNL?
>
> I'm using apache2 with the latest mod_lisp2 and TBNL 0.9.9 on a
> Debian Etch system.

Your information is sent in chunks to mod_lisp, but that's not what
your browser sees.  It sees what Apache will eventually send.

You can use SEND-HEADERS as described above to achieve what you want,
but only if you use TBNL in "stand-alone mode" or if you use a
front-end like Hunchentoot.  (I'm not sure about Araneida, maybe
that'll also work.)

Cheers,
Edi.



More information about the Tbnl-devel mailing list