Expiration#

Utility functions for parsing and converting expiration values

requests_cache.policy.expiration.get_expiration_datetime(expire_after, start_time=None, negative_delta=False, ignore_invalid_httpdate=False)[source]#

Convert an expiration value in any supported format to an absolute datetime

Parameters:
Return type:

Optional[datetime]

requests_cache.policy.expiration.get_expiration_seconds(expire_after)[source]#

Convert an expiration value in any supported format to an expiration time in seconds

Parameters:

expire_after (Union[None, int, float, str, datetime, timedelta]) –

Return type:

int

requests_cache.policy.expiration.get_url_expiration(url, urls_expire_after=None)[source]#

Check for a matching per-URL expiration, if any

Parameters:
Return type:

Union[None, int, float, str, datetime, timedelta]