summaryrefslogtreecommitdiff
path: root/requests_cache/session.py
diff options
context:
space:
mode:
authorManuel Eggimann <meggimann@iis.ee.ethz.ch>2021-11-29 13:53:06 +0100
committerManuel Eggimann <meggimann@iis.ee.ethz.ch>2021-11-29 13:53:06 +0100
commit0d26cb768d19c75c1f882b82f859358732e69058 (patch)
tree44488ae7ea7cff1b50bfae31cf5008d577059358 /requests_cache/session.py
parentebf04760d14164c86b376e3ba956da00e50efbdc (diff)
downloadrequests-cache-0d26cb768d19c75c1f882b82f859358732e69058.tar.gz
Update cache entry expiration date in case of 304 Not Modified
Diffstat (limited to 'requests_cache/session.py')
-rw-r--r--requests_cache/session.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/requests_cache/session.py b/requests_cache/session.py
index 9b2531d..2468bdb 100644
--- a/requests_cache/session.py
+++ b/requests_cache/session.py
@@ -180,7 +180,12 @@ class CacheMixin(MIXIN_BASE):
if self._is_cacheable(response, actions):
self.cache.save_response(response, actions.cache_key, actions.expires)
elif cached_response and response.status_code == 304:
- logger.debug(f'Response for URL {request.url} has not been modified; using cached response')
+ logger.debug(
+ f'Response for URL {request.url} has not been modified; using cached response and updating expiration date.'
+ )
+ # Update the cache expiration date. Since we performed validation,
+ # the cache entry may be marked as fresh again.
+ self.cache.save_response(cached_response, actions.cache_key, actions.expires)
return cached_response
else:
logger.debug(f'Skipping cache write for URL: {request.url}')