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)
| 101 | |
| 102 | |
| 103 | def 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 | |
| 119 | def set_response_etag(response): |