Submitted by : 127.0.0.1 at: 2005-03-24T13:54:24+00:00 (12 years ago)
Name :
Category : Severity : Status :
Optional subject :  
Optional comment :

I've prepared the Cache headers for ZwikiPages? like this using the Caching Policy Manager: Expires: now Cache-Control: max-age=0; must-revalidate Last-Modified: current/modified

(( In detail it looks like: jens@schlepptop:~/tmp$ wget -S http://localhost:9673/jens/jens-wiki/ZWiki --22:44:09-- http://localhost:9673/jens/jens-wiki/ZWiki

=> `ZWiki.8'

Auflösen des Hostnamen »localhost«.... 127.0.0.1 Verbindungsaufbau zu localhost[127.0.0.1]:9673... verbunden. HTTP Anforderung gesendet, warte auf Antwort...

1 HTTP/1.0 200 OK 2 Server: Zope/(Zope 2.7.4-0, python 2.3.5, linux2) ZServer?/1.1 Plone/2.0.4 3 Date: Thu, 24 Mar 2005 21:44:10 GMT 4 Content-Length: 30060 5 Content-Language:

-> 6 Expires: Thu, 24 Mar 2005 21:44:10 GMT -> 7 Last-Modified: Wed, 09 Mar 2005 19:25:49 GMT

8 Connection: Keep-Alive 9 Cache-Control: max-age=0, must-revalidate

10 Content-Type: text/html;charset=utf-8 ))

I have a caching Apache in front of my Plone+Zwiki. The caching-proxy stores the file. But for each new request the caching-proxy must ask zwiki, whether the file has changed in between, like this:

$ telnet localhost 9673 | head -40 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GET /jens/jens-wiki/ZWiki HTTP/1.1 If-Modified-Since: Wed, 09 Mar 2005 19:25:49 GMT

HTTP/1.1 200 OK Server: Zope/(Zope 2.7.4-0, python 2.3.5, linux2) ZServer?/1.1 Plone/2.0.4 Date: Thu, 24 Mar 2005 21:46:11 GMT Content-Length: 30060 Content-Language: Expires: Thu, 24 Mar 2005 21:46:11 GMT Last-Modified: Wed, 09 Mar 2005 19:25:49 GMT Cache-Control: max-age=0, must-revalidate Content-Type: text/html;charset=utf-8

<all the data>

** N.B.: Not only a 304 (Not Modified) is sent but the whole data **

Here is how CMFCore/FSFile? does it:

# HTTP If-Modified-Since header handling. header=REQUEST.get_header('If-Modified-Since', None) if header is not None:

header=string.split(header, ';')[0]? # Some proxies seem to send invalid date strings for this # header. If the date string is not valid, we ignore it # rather than raise an error to be generally consistent # with common servers such as Apache (which can usually # understand the screwy date string as a lucky side effect # of the way they parse it). try: mod_since=long(DateTime?(header).timeTime()) except: mod_since=None if mod_since is not None:

last_mod = self._file_mod_time if last_mod > 0 and last_mod <= mod_since:

# Set header values since apache caching will return # Content-Length of 0 in response if size is not set here RESPONSE.setHeader('Last-Modified', rfc1123_date(last_mod)) RESPONSE.setHeader('Content-Type', self.content_type) RESPONSE.setHeader('Content-Length', self.get_size()) RESPONSE.setStatus(304) return ''

I thought about adding this to wikipage function, but it does not seem to be applied. Usually this is done in the index_html function, but there is not such one for ZWiki, so I dont know where this code could be incorporated. Hints?

Grep for "setHeader(304)" to see how other content types handle this, if you want to fix this yourself (I'd be very glad).

regards, Jens

override? --DeanG, Thu, 24 Mar 2005 14:37:35 -0800 reply

Is there some kind of override? A dynamic page such as RecentChanges? or RSS feed would want to use the top item's date...

Readable bug description --Sat, 26 Mar 2005 01:30:37 -0800 reply

I guess the original bug report is hardly readable. Here comes another try, with the report put into "pre" tags (HTH, though there is no "preview"):

<pre> I've prepared the Cache headers for ZwikiPages? like this using the Caching Policy Manager: Expires: now Cache-Control: max-age=0; must-revalidate Last-Modified: current/modified

(( In detail it looks like: jens@schlepptop:~/tmp$ wget -S http://localhost:9673/jens/jens-wiki/ZWiki --22:44:09-- http://localhost:9673/jens/jens-wiki/ZWiki

=> `ZWiki.8'

Auflösen des Hostnamen »localhost«.... 127.0.0.1 Verbindungsaufbau zu localhost[127.0.0.1]:9673... verbunden. HTTP Anforderung gesendet, warte auf Antwort...

1 HTTP/1.0 200 OK 2 Server: Zope/(Zope 2.7.4-0, python 2.3.5, linux2) ZServer?/1.1 Plone/2.0.4 3 Date: Thu, 24 Mar 2005 21:44:10 GMT 4 Content-Length: 30060 5 Content-Language:

-> 6 Expires: Thu, 24 Mar 2005 21:44:10 GMT -> 7 Last-Modified: Wed, 09 Mar 2005 19:25:49 GMT

8 Connection: Keep-Alive 9 Cache-Control: max-age=0, must-revalidate

10 Content-Type: text/html;charset=utf-8 ))

I have a caching Apache in front of my Plone+Zwiki. The caching-proxy stores the file. But for each new request the caching-proxy must ask zwiki, whether the file has changed in between, like this:

$ telnet localhost 9673 | head -40 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GET /jens/jens-wiki/ZWiki HTTP/1.1 If-Modified-Since: Wed, 09 Mar 2005 19:25:49 GMT

HTTP/1.1 200 OK Server: Zope/(Zope 2.7.4-0, python 2.3.5, linux2) ZServer?/1.1 Plone/2.0.4 Date: Thu, 24 Mar 2005 21:46:11 GMT Content-Length: 30060 Content-Language: Expires: Thu, 24 Mar 2005 21:46:11 GMT Last-Modified: Wed, 09 Mar 2005 19:25:49 GMT Cache-Control: max-age=0, must-revalidate Content-Type: text/html;charset=utf-8

<all the data>

** N.B.: Not only a 304 (Not Modified) is sent but the whole data **

Here is how CMFCore/FSFile? does it:

# HTTP If-Modified-Since header handling. header=REQUEST.get_header('If-Modified-Since', None) if header is not None:

header=string.split(header, ';')[0]? # Some proxies seem to send invalid date strings for this # header. If the date string is not valid, we ignore it # rather than raise an error to be generally consistent # with common servers such as Apache (which can usually # understand the screwy date string as a lucky side effect # of the way they parse it). try: mod_since=long(DateTime?(header).timeTime()) except: mod_since=None if mod_since is not None:

last_mod = self._file_mod_time if last_mod > 0 and last_mod <= mod_since:

# Set header values since apache caching will return # Content-Length of 0 in response if size is not set here RESPONSE.setHeader('Last-Modified', rfc1123_date(last_mod)) RESPONSE.setHeader('Content-Type', self.content_type) RESPONSE.setHeader('Content-Length', self.get_size()) RESPONSE.setStatus(304) return ''

I thought about adding this to wikipage function, but it does not seem to be applied. Usually this is done in the index_html function, but there is not such one for ZWiki, so I dont know where this code could be incorporated. Hints?

Grep for "setHeader(304)" to see how other content types handle this, if you want to fix this yourself (I'd be very glad).

regards, Jens

</pre>

Not implemented yet... will do --betabug, Tue, 27 Feb 2007 10:47:22 +0000 reply

As for the note: "Not only a 304 (Not Modified) is sent but the whole data " -- that's not exactly correct. We do not send a 304 and then the data. We send a 200 and the data. If-modified-since handling is just not implemented. Since this is on my personal wishlist I'll start to look into implementing this :-)

**It's actually easy.... but there's a little problem with dtml logic
pages** --betabug, Tue, 27 Feb 2007 12:13:35 +0000 reply

Since I've done this before (see http://betabug.ch/blogs/ch-athens/333) it was quite easy to implement... but there is a big, big question mark with dtml pages like the IssueTracker. If you add an Issue to the IssueTracker the "edit time" of the IssueTracker itself does not change, so browsers get the "old" tracker view over and over. Gotta think about how to solve this one for a while.

Patch is in darcs, by default disabled though --betabug, Tue, 27 Feb 2007 14:46:37 +0000 reply

Status: open => closed

Just sent off the patch to implement this to the darcs repository. By default handling "Conditional HTTP Get" is off though.

To enable it, one has to set a 'conditional_http_get' boolean property to True. Detailed docs are coming too.

Docs, RSS --betabug, Tue, 27 Feb 2007 16:17:17 +0000 reply

Docs are in [How to enable "conditional HTTP GET" (304)]?. The next patch enables this for our standard RSS feeds too.

... --simon, Sat, 24 Mar 2007 15:52:14 +0000 reply

Name: '#1077 zwiki always answers 200 to If-Modified-Since Requests, newer 304' => '#1077 conditional HTTP GET (304) handling' Severity: normal => wishlist

See also #1316 FireFox doesn't load changes after editing with 304 enabled