diff options
| author | Jozef <knaperek@users.noreply.github.com> | 2017-12-04 14:57:55 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-12-04 08:57:55 -0500 |
| commit | 3d94ee85005ff658f9419269a6719cbbf7903dab (patch) | |
| tree | 478096733e001093dc31e167354d847f1905ceb3 /django/utils/cache.py | |
| parent | bee4c2baede18d8c8c0a29cd9affb18074dafd3a (diff) | |
Simplified django.utils.cache.get_max_age().
Diffstat (limited to 'django/utils/cache.py')
| -rw-r--r-- | django/utils/cache.py | 9 |
1 files 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): |
