2007-07-16 20:22:38 +00:00
|
|
|
import cherrypy
|
|
|
|
|
|
|
|
|
|
|
|
def strongly_expire( function ):
|
2007-09-01 23:46:15 +00:00
|
|
|
"""
|
|
|
|
Decorator that sends headers that instruct browsers and proxies not to cache.
|
|
|
|
"""
|
|
|
|
def expire( *args, **kwargs ):
|
2008-10-08 22:56:30 +00:00
|
|
|
cherrypy.response.headers[ "Expires" ] = "Sun, 19 Nov 1978 05:00:00 GMT"
|
|
|
|
cherrypy.response.headers[ "Cache-Control" ] = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
|
|
|
|
cherrypy.response.headers[ "Pragma" ] = "no-cache"
|
2007-07-16 20:22:38 +00:00
|
|
|
|
2008-10-08 22:56:30 +00:00
|
|
|
return function( *args, **kwargs )
|
2007-07-16 20:22:38 +00:00
|
|
|
|
2007-09-01 23:46:15 +00:00
|
|
|
return expire
|
2008-05-06 21:41:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
def weakly_expire( function ):
|
|
|
|
"""
|
|
|
|
Decorator that sends headers that instruct browsers and proxies not to cache. This cache busting
|
|
|
|
isn't as strong as the @strongly_expire decorator, but it has the distinct benefit of not
|
|
|
|
breaking Internet Explorer HTTPS file downloads.
|
|
|
|
"""
|
|
|
|
def expire( *args, **kwargs ):
|
2008-10-08 22:56:30 +00:00
|
|
|
cherrypy.response.headers[ "Expires" ] = "Sun, 19 Nov 1978 05:00:00 GMT"
|
2008-05-06 21:41:00 +00:00
|
|
|
|
2008-10-08 22:56:30 +00:00
|
|
|
return function( *args, **kwargs )
|
2008-05-06 21:41:00 +00:00
|
|
|
|
|
|
|
return expire
|