mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-01 00:43:37 +00:00
Fixed couple bugs in cache control
This commit is contained in:
parent
381049c373
commit
9124c528a8
2 changed files with 4 additions and 4 deletions
|
@ -225,7 +225,7 @@ class CacheController(object):
|
||||||
# cache when there is a max-age > 0
|
# cache when there is a max-age > 0
|
||||||
if cc and cc.get('max-age'):
|
if cc and cc.get('max-age'):
|
||||||
if int(cc['max-age']) > 0:
|
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)
|
cc['max-age'] = int(cache_max_age)
|
||||||
resp.headers['cache-control'] = ''.join(['%s=%s' % (key, value) for (key, value) in cc.items()])
|
resp.headers['cache-control'] = ''.join(['%s=%s' % (key, value) for (key, value) in cc.items()])
|
||||||
self.cache.set(cache_url, resp)
|
self.cache.set(cache_url, resp)
|
||||||
|
|
|
@ -7,17 +7,17 @@ class CacheControlSession(Session):
|
||||||
def get(self, *args, **kw):
|
def get(self, *args, **kw):
|
||||||
# auto-cache response
|
# auto-cache response
|
||||||
self.cache_auto = False
|
self.cache_auto = False
|
||||||
if kw.has_key('cache_auto'):
|
if kw.get('cache_auto'):
|
||||||
self.cache_auto = kw.pop('cache_auto')
|
self.cache_auto = kw.pop('cache_auto')
|
||||||
|
|
||||||
# urls allowed to cache
|
# urls allowed to cache
|
||||||
self.cache_urls = []
|
self.cache_urls = []
|
||||||
if kw.has_key('cache_urls'):
|
if kw.get('cache_urls'):
|
||||||
self.cache_urls = [str(args[0])] + kw.pop('cache_urls')
|
self.cache_urls = [str(args[0])] + kw.pop('cache_urls')
|
||||||
|
|
||||||
# timeout for cached responses
|
# timeout for cached responses
|
||||||
self.cache_max_age = None
|
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'))
|
self.cache_max_age = int(kw.pop('cache_max_age'))
|
||||||
|
|
||||||
return super(CacheControlSession, self).get(*args, **kw)
|
return super(CacheControlSession, self).get(*args, **kw)
|
||||||
|
|
Loading…
Reference in a new issue