From 3d94ee85005ff658f9419269a6719cbbf7903dab Mon Sep 17 00:00:00 2001 From: Jozef Date: Mon, 4 Dec 2017 14:57:55 +0100 Subject: [PATCH] Simplified django.utils.cache.get_max_age(). --- django/utils/cache.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/django/utils/cache.py b/django/utils/cache.py index 81fc44293e..ce7faaedbc 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):