diff options
| -rwxr-xr-x | requests_cache/models/response.py | 2 | ||||
| -rw-r--r-- | requests_cache/policy/actions.py | 2 | ||||
| -rw-r--r-- | requests_cache/session.py | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/requests_cache/models/response.py b/requests_cache/models/response.py index 9ad3a1a..7d40998 100755 --- a/requests_cache/models/response.py +++ b/requests_cache/models/response.py @@ -146,7 +146,7 @@ class CachedResponse(BaseResponse, RichMixin): def expires_unix(self) -> Optional[int]: """Get expiration time as a Unix timestamp""" seconds = self.expires_delta - return round(time() + seconds) if seconds else None + return round(time() + seconds) if seconds is not None else None @property def next(self) -> Optional[PreparedRequest]: diff --git a/requests_cache/policy/actions.py b/requests_cache/policy/actions.py index a56d30e..fd61507 100644 --- a/requests_cache/policy/actions.py +++ b/requests_cache/policy/actions.py @@ -172,8 +172,8 @@ class CacheActions(RichMixin): self._update_from_response_headers(directives) # If "expired" but there's a validator, save it to the cache and revalidate on use - do_not_cache = self.expire_after == DO_NOT_CACHE skip_stale = self.expire_after == EXPIRE_IMMEDIATELY and not directives.has_validator + do_not_cache = self.expire_after == DO_NOT_CACHE # Apply filter callback, if any callback = self._settings.filter_fn diff --git a/requests_cache/session.py b/requests_cache/session.py index 40960ec..de0a0cd 100644 --- a/requests_cache/session.py +++ b/requests_cache/session.py @@ -297,10 +297,10 @@ class CacheMixin(MIXIN_BASE): self.cache.close() def remove_expired_responses(self, expire_after: ExpirationTime = None): - """Remove expired responses from the cache, optionally with revalidation + """Remove expired and invalid responses from the cache, and optionally reset expiration Args: - expire_after: A new expiration time used to revalidate the cache + expire_after: A new expiration time to set on existing cache items """ self.cache.remove_expired_responses(expire_after) |
