Simplified django.utils.cache.get_max_age().

This commit is contained in:
Jozef 2017-12-04 14:57:55 +01:00 committed by Tim Graham
parent bee4c2baed
commit 3d94ee8500
1 changed files with 4 additions and 5 deletions

View File

@ -93,10 +93,9 @@ def get_max_age(response):
if not response.has_header('Cache-Control'): if not response.has_header('Cache-Control'):
return return
cc = dict(_to_tuple(el) for el in cc_delim_re.split(response['Cache-Control'])) cc = dict(_to_tuple(el) for el in cc_delim_re.split(response['Cache-Control']))
if 'max-age' in cc:
try: try:
return int(cc['max-age']) return int(cc['max-age'])
except (ValueError, TypeError): except (ValueError, TypeError, KeyError):
pass pass