Fixed couple bugs in cache control

This commit is contained in:
echel0n 2014-03-29 22:02:32 -07:00
parent 381049c373
commit 9124c528a8
2 changed files with 4 additions and 4 deletions

View file

@ -225,7 +225,7 @@ class CacheController(object):
# cache when there is a max-age > 0
if cc and cc.get('max-age'):
if int(cc['max-age']) > 0:
if isinstance(cache_max_age, (int, long)):
if isinstance(cache_max_age, (int)):
cc['max-age'] = int(cache_max_age)
resp.headers['cache-control'] = ''.join(['%s=%s' % (key, value) for (key, value) in cc.items()])
self.cache.set(cache_url, resp)

View file

@ -7,17 +7,17 @@ class CacheControlSession(Session):
def get(self, *args, **kw):
# auto-cache response
self.cache_auto = False
if kw.has_key('cache_auto'):
if kw.get('cache_auto'):
self.cache_auto = kw.pop('cache_auto')
# urls allowed to cache
self.cache_urls = []
if kw.has_key('cache_urls'):
if kw.get('cache_urls'):
self.cache_urls = [str(args[0])] + kw.pop('cache_urls')
# timeout for cached responses
self.cache_max_age = None
if kw.has_key('cache_max_age'):
if kw.get('cache_max_age'):
self.cache_max_age = int(kw.pop('cache_max_age'))
return super(CacheControlSession, self).get(*args, **kw)