tools.expires is completely broken

119 views
Skip to first unread message

Jae

unread,
Jul 31, 2009, 4:04:52 PM7/31/09
to cherrypy-devel
I noticed that all of my static files were not returning Expires
headers, even though I set the correct tools.expires settings in the
config file:

[/static]
tools.staticdir.on = True
tools.staticdir.dir = "static"
tools.expires.on = True
tools.expires.secs = 1000

I looked over the source and found that cacheable responses never get
the "Expires" response header set! (Go ahead, check out the cherrypy/
lib/caching.py source file, very bottom)

I nailed down the problem to this commit: http://www.cherrypy.org/changeset/1208
. Notice that the description of the commit is completely the opposite
of what the python revision is doing. The only time the 'Expires'
header gets set is if the response is a "noncacheable" object.

I think the problem is that the "expires" tool is trying to do three
different things simultaneously... make responses non-cacheable, make
responses expire immediately, and make responses expire in the
future.

Anyways, here's my patch. Unfortunately I don't have access to the
cherrypy trac page, so hopefully someone here will pick this up, and
fix as necessary.

patch for lib/caching.py: http://pastebin.com/f23025149
patch for test/test_caching.py: http://pastebin.com/m7852325b

viva la cherrypy.

- Jae Kwon

fumanchu

unread,
Aug 6, 2009, 2:53:17 AM8/6/09
to cherrypy-devel
Fixed in http://www.cherrypy.org/changeset/2493, although I chose not
to integrate the 'no_cache' logic in the patch; I couldn't see why we
would check for the presence of a header in order to set the same
header.


Robert Brewer
fuma...@aminus.org

Jae Kwon

unread,
Aug 6, 2009, 4:44:54 PM8/6/09
to cherryp...@googlegroups.com
>
> Fixed in http://www.cherrypy.org/changeset/2493, although I chose not
> to integrate the 'no_cache' logic in the patch; I couldn't see why we
> would check for the presence of a header in order to set the same
> header.
>

danke

Reply all
Reply to author
Forward
0 new messages