[Zope-dev] Streaming Response

Brett Carter brett@kavi.com
Fri, 18 Apr 2003 10:56:11 -0700


> Well, do they? Most browsers try to show content as fast as possible.
> There are even CSS-standards for making it possible to predict a tables
> layout ahead to be able to render it as fast as possible (before it is 
> completely loaded).
> The main reason of this I guess is because people usually start reading the 
> top of the
> page and showing it make it appear to load faster for the visitor.
> Hence, your browser/site appears faster.

Huh, well perhaps I was wrong, I dunno I've never tried something exactly
like that.
 
> This could be useful for other stuff as well (except streaming large object,
> which should never be saved in the ZODB by the way, be cause it bloats the
> memory when the object is loaded. It should be stream from a file, and not
> by reading the entire file as most file system object product I reviewed 
> does
> including LocalFS which I have made a patch for).

Cool, I'm actually working on a project where I need to stream out a large
file from LocalFS, could you send me that patch?  I've also made a patch to
LocalFS to allow you to specify paths relative to INSTANCE_HOME, or any
environment variable for that matter.
 
> One use would be sending response in a long-time execution of a pack
> or other maintenance activities. It's a great thing to see how the process
> get along and that it's not halted.

Yeah, actually this is kinda a major problem if you're serving zope via
a reverse proxy and rewrite rules -- if any page takes longer than 90-ish
seconds to load, the reverse proxy will time out and close the connection, 
causing most browsers to re-send the request.  This is a problem for long
running processes, since you get in an infinite loop, with a bunch of processes
getting started on top of each other.  That's exactly why I wrote the HTTPpush
library, the stream of data prevents the browser from timing out.

> In such a process you can't predict the Content-Length, because you
> don't know ahead what messages the might pop-up.
> 
> So the question is what happens if the Content-Length is excluded.
> In my test with text/html content nothing happens and it works fine.
> Other content types may behave differently depending on the client.

I don't think content-length is required for some types, check the HTTP rfc.

-Brett