[Zope-dev] Adding gzip compression to HTTPResponse.py

Toby Dickenson tdickenson@geminidataloggers.com
Thu, 07 Feb 2002 10:15:49 +0000


On Wed, 6 Feb 2002 11:22:23 -0500, "Brad Clements" <bkc@murkworks.com>
wrote:

>> >Also, RESPONSE.setBody really should have access to REQUEST.headers.
>> >What's the clean way to do that? Just pass the request object to =
response
>> >object's init method?
>>=20
>> RESPONSE objects have a REQUEST attribute
>
>Are you sure? I know that request objects have a response object. But =
looking at=20
>publish.py doesn't look like it goes the other way.

D'Oh, you are right.

A better recommendation is to look at make_request in
ZServer/HTTPResponse. It probably does make sense for the request
headers to be stored in the response object, and I suspect this would
be the place to do it.

>I am using Apache with mod_rewrite. Sure, it'd be great to compression =
there, but=20
>Apache doesn't cache, you need squid for that, right?

I know it can be done with apache, but I prefer squid.

>I agree, Transfer Encoding is the way to go, but based on remarks at:
>
>http://www.iol.ie/~alank/python/httpcomp.html#encoding
>
>I stuck with the simpler to understand content-encoding.

I think those remarks are misleading, and I dont find rfc2616 at all
unclear in *this* area.

Content-Encoding is a property of the entity being transferred. It is
an end-to-end property (that is, from origin server to browser) and
intermediate proxies or caches are not permitted to tamper with it.

Transfer-Encoding is a property of the HTTP conversation (that is the
conversation from browser to cache, from cache to another cache, from
cache to front-end-proxy, and front-end-proxy to back-end-zope). If
both ends of a conversation implement the same transfer-encoding
(gzip, rsync, etc) then they could transparently apply the encoding as
the document travels over the wire.

My conclusions:

1. Adding Transfer-Encoding support to Zope is unnecessary if you are
using a front-end proxy (there are many reasons why most people
should, but some important exceptions where you need not).

2. Adding Content-Encoding support to Zope is a good thing only if
your front-end proxy does not support on-the-fly Transfer-Encoding. I
think apache does, but squid does not.



Toby Dickenson
tdickenson@geminidataloggers.com