diff --git a/httpx_caching/_policy.py b/httpx_caching/_policy.py index df0bd5e..fd5c3fb 100644 --- a/httpx_caching/_policy.py +++ b/httpx_caching/_policy.py @@ -222,8 +222,12 @@ def try_from_cache_policy( # determine freshness freshness_lifetime = 0 + # Check the s-maxage pragma in the cache control header + if "s-maxage" in resp_cc: + freshness_lifetime = resp_cc["s-maxage"] + logger.debug("Freshness lifetime from s-maxage: %i", freshness_lifetime) # Check the max-age pragma in the cache control header - if "max-age" in resp_cc: + elif "max-age" in resp_cc: freshness_lifetime = resp_cc["max-age"] logger.debug("Freshness lifetime from max-age: %i", freshness_lifetime) # If there isn't a max-age, check for an expires header