Hello. Static.File doesn't seem to support any of the cache features that modern browsers use. There are various HTTP headers that govern this, including Etag, Cache-Control, Expires, etc. The Twisted server returns a comparatively minimal set of headers (hit twistedmatrix.com and look at the headers). Also, as far as I can tell, a "good citizen" HTTPD changes the response from a "200" to another response code that indicates "nothing new here", under certain circumstances. OR, it lets the browser figure that out... but it has to give the browser enough headers for it to do so. Is there a subclass of Static.File somewhere in Twisted that supports these features, or am I perhaps looking in the wrong place for this functionality? Thanks.
This was suggested by "jerub" on #twisted.web for Nevow usage. Maybe you'll find it helpful for figuring out how to deal with the caching issue with twisted.web as well. Best regards, Ed class StaticData(static.Data): """ I am an override to Nevow's static.Data class to render static objects with the time they were created. Hopefully won't be necessary with a newer release of Nevow """ def __init__(self, *arg, **kw): self.createTime = time.time() static.Data.__init__(self, *arg, **kw) def renderHTTP(self, ctx): request = IRequest(ctx) request.setLastModified(self.createTime) return static.Data.renderHTTP(self, ctx) On Thursday 31 March 2005 01:47 pm, Matt Feifarek wrote:
Hello.
Static.File doesn't seem to support any of the cache features that modern browsers use.
There are various HTTP headers that govern this, including Etag, Cache-Control, Expires, etc. The Twisted server returns a comparatively minimal set of headers (hit twistedmatrix.com and look at the headers).
Also, as far as I can tell, a "good citizen" HTTPD changes the response from a "200" to another response code that indicates "nothing new here", under certain circumstances. OR, it lets the browser figure that out... but it has to give the browser enough headers for it to do so.
Is there a subclass of Static.File somewhere in Twisted that supports these features, or am I perhaps looking in the wrong place for this functionality?
On Mar 31, 2005, at 4:47 PM, Matt Feifarek wrote:
Hello.
Static.File doesn't seem to support any of the cache features that modern browsers use.
static.File supports If-Modified-Since and Last-Modified: Try running: $ curl -H'If-Modified-Since: Mon, 28 Mar 2005 04:58:37 GMT' -i 'http://twistedmatrix.com/' and notice how it returns a 304 Not Modified. Cache-Control and Expires are not relevant to a static file resource. But yes, it's not returning an ETag. James
participants (3)
-
Ed Suominen
-
James Y Knight
-
Matt Feifarek