tools.expires is completely broken

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

tools.expires is completely broken

Jae-8

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

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-devel" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cherrypy-devel
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: tools.expires is completely broken

Robert Brewer-4

On Jul 31, 1:04 pm, Jae <[hidden email]> wrote:

> 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.

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
[hidden email]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-devel" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cherrypy-devel
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: tools.expires is completely broken

Jae-8

>
> 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

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-devel" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cherrypy-devel
-~----------~----~----~----~------~----~------~--~---

Loading...