diff options
author | Jordan Cook <jordan.cook@pioneer.com> | 2022-05-03 14:52:37 -0500 |
---|---|---|
committer | Jordan Cook <jordan.cook@pioneer.com> | 2022-05-03 14:52:37 -0500 |
commit | 7f4c20525770d463c5526fa601e8e3b5472cf2e6 (patch) | |
tree | 98bf214cb4ad9395f136a6a93010f0ada54e3a20 /requests_cache/policy | |
parent | a300510c4ba087fd41d31c379a9d03e3b80b55aa (diff) | |
download | requests-cache-7f4c20525770d463c5526fa601e8e3b5472cf2e6.tar.gz |
Add always_revalidate session option
Diffstat (limited to 'requests_cache/policy')
-rw-r--r-- | requests_cache/policy/actions.py | 3 | ||||
-rw-r--r-- | requests_cache/policy/settings.py | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/requests_cache/policy/actions.py b/requests_cache/policy/actions.py index fd61507..cdacefd 100644 --- a/requests_cache/policy/actions.py +++ b/requests_cache/policy/actions.py @@ -203,6 +203,7 @@ class CacheActions(RichMixin): logger.debug(f'Response for URL {response.request.url} has not been modified') cached_response.expires = self.expires cached_response.headers.update(response.headers) + cached_response.revalidated = True return cached_response def _update_from_response_headers(self, directives: CacheDirectives): @@ -230,7 +231,7 @@ class CacheActions(RichMixin): or self._refresh or directives.no_cache or directives.must_revalidate - and directives.max_age == 0 + or (self._settings.always_revalidate and directives.has_validator) ) # Add the appropriate validation headers, if needed diff --git a/requests_cache/policy/settings.py b/requests_cache/policy/settings.py index 7888e45..2f9b9fe 100644 --- a/requests_cache/policy/settings.py +++ b/requests_cache/policy/settings.py @@ -25,6 +25,7 @@ class CacheSettings(RichMixin): allowable_codes: Iterable[int] = field(default=DEFAULT_STATUS_CODES) allowable_methods: Iterable[str] = field(default=DEFAULT_METHODS) + always_revalidate: bool = field(default=None) cache_control: bool = field(default=False) disabled: bool = field(default=False) expire_after: ExpirationTime = field(default=None) |