Skip to content

Commit

Permalink
Simplified django.utils.cache.get_max_age().
Browse files Browse the repository at this point in the history
  • Loading branch information
knaperek authored and timgraham committed Dec 4, 2017
1 parent bee4c2b commit 3d94ee8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions django/utils/cache.py
Expand Up @@ -93,11 +93,10 @@ def get_max_age(response):
if not response.has_header('Cache-Control'):
return
cc = dict(_to_tuple(el) for el in cc_delim_re.split(response['Cache-Control']))
if 'max-age' in cc:
try:
return int(cc['max-age'])
except (ValueError, TypeError):
pass
try:
return int(cc['max-age'])
except (ValueError, TypeError, KeyError):
pass


def set_response_etag(response):
Expand Down

0 comments on commit 3d94ee8

Please sign in to comment.