MCPcopy
hub / github.com/django/django / get_max_age

Function get_max_age

django/utils/cache.py:103–116  ·  view source on GitHub ↗

Return the max-age from the response Cache-Control header as an integer, or None if it wasn't found or wasn't an integer.

(response)

Source from the content-addressed store, hash-verified

101
102
103def get_max_age(response):
104 """
105 Return the max-age from the response Cache-Control header as an integer,
106 or None if it wasn't found or wasn't an integer.
107 """
108 if not response.has_header("Cache-Control"):
109 return
110 cc = dict(
111 _to_tuple(el) for el in cc_delim_re.split(response.headers["Cache-Control"])
112 )
113 try:
114 return int(cc["max-age"])
115 except (ValueError, TypeError, KeyError):
116 pass
117
118
119def set_response_etag(response):

Callers 14

process_responseMethod · 0.90
process_requestMethod · 0.90
test_admin_indexMethod · 0.90
test_app_indexMethod · 0.90
test_model_indexMethod · 0.90
test_model_addMethod · 0.90
test_model_viewMethod · 0.90
test_model_historyMethod · 0.90
test_model_deleteMethod · 0.90
test_loginMethod · 0.90
test_logoutMethod · 0.90
test_password_changeMethod · 0.90

Calls 3

_to_tupleFunction · 0.85
has_headerMethod · 0.80
splitMethod · 0.45

Tested by 12

test_admin_indexMethod · 0.72
test_app_indexMethod · 0.72
test_model_indexMethod · 0.72
test_model_addMethod · 0.72
test_model_viewMethod · 0.72
test_model_historyMethod · 0.72
test_model_deleteMethod · 0.72
test_loginMethod · 0.72
test_logoutMethod · 0.72
test_password_changeMethod · 0.72
test_JS_i18nMethod · 0.72