diff options
author | Jordan Cook <jordan.cook.git@proton.me> | 2023-03-13 12:26:27 -0500 |
---|---|---|
committer | Jordan Cook <jordan.cook.git@proton.me> | 2023-03-24 18:50:18 -0500 |
commit | 5bcb137ff944533210036d5fcefe0a5f87cde96c (patch) | |
tree | ad8c7daec7cfab477e6129c7e4ff99b8000822ac /requests_cache | |
parent | 0dcf40989503df7041eb9f0c4789aecea78cbd5c (diff) | |
download | requests-cache-5bcb137ff944533210036d5fcefe0a5f87cde96c.tar.gz |
Ignore Cache-Control: must-revalidate and no-cache when cache_control=False
Diffstat (limited to 'requests_cache')
-rw-r--r-- | requests_cache/policy/actions.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/requests_cache/policy/actions.py b/requests_cache/policy/actions.py index 50960cb..034cb72 100644 --- a/requests_cache/policy/actions.py +++ b/requests_cache/policy/actions.py @@ -268,16 +268,17 @@ class CacheActions(RichMixin): triggered by a stale response, request headers, or cached response headers. """ directives = CacheDirectives.from_headers(cached_response.headers) + # These conditions always apply revalidate = directives.has_validator and ( - cached_response.is_expired - or self._refresh - or directives.no_cache - or directives.must_revalidate - or (self._settings.always_revalidate and directives.has_validator) + cached_response.is_expired or self._refresh or self._settings.always_revalidate + ) + # These conditions only apply if cache_control=True + cc_revalidate = self._settings.cache_control and ( + directives.no_cache or directives.must_revalidate ) # Add the appropriate validation headers, if needed - if revalidate: + if revalidate or cc_revalidate: if directives.etag: self._validation_headers['If-None-Match'] = directives.etag if directives.last_modified: |