[Zope] HTTP caching headers in Zope: mini-Howto

Toby Dickenson tdickenson@geminidataloggers.com
Mon, 17 Apr 2000 08:58:05 +0100


On Sun, 16 Apr 2000 18:43:04 +0300, Itamar Shtull-Trauring
<itamars@ibm.net> wrote:

>header=REQUEST.get_header('If-Modified-Since', None)
>if header is not None:
>    header=_.string.split(header, ';')[0]
>    mod_since=int(_.DateTime(header).timeTime())
>
>    if int(mod_time) <= mod_since:
>        RESPONSE.setStatus(304)
>        RESPONSE.write('')
>        raise "NotModified", ''

I don't think that response.write('') is a good idea. It causes
ZServer to switch to streaming output mode, which is a little less
efficient. In particular HTTP/1.0 clients can't use persistent
connections. For other clients the difference isn't great, but still
significant.

This might be better as.....

    if int(mod_time) <= mod_since:
        RESPONSE.setStatus(304)
        return 1

>	<dtml-unless dynamicpage>
>	<dtml-call "httpHandler(this(), REQUEST, RESPONSE)">
>	</dtml-unless>

....and.... 

        <dtml-unless dynamicpage>
        <dtml-if "httpHandler(this(), REQUEST, RESPONSE)">
                <dtml-return "''">
        </dtml-if>
        </dtml-unless>



Toby Dickenson
tdickenson@geminidataloggers.com