diff --git a/django/utils/cache.py b/django/utils/cache.py index 81fc44293ee7..ce7faaedbca1 100644 --- a/django/utils/cache.py +++ b/django/utils/cache.py @@ -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):