summaryrefslogtreecommitdiff
path: root/requests_cache/session.py
diff options
context:
space:
mode:
authorJordan Cook <jordan.cook@pioneer.com>2022-05-21 12:54:56 -0500
committerJordan Cook <jordan.cook@pioneer.com>2022-06-16 15:45:42 -0500
commit20dcc26d7d49d2ec8ee9571161a2722bb09fed25 (patch)
treee99bc0a4597004cf6eb63ed26e6d980e0b0c1064 /requests_cache/session.py
parentccaf6b0b2d9a7dc612b5129e1c2841a04a2b587c (diff)
downloadrequests-cache-20dcc26d7d49d2ec8ee9571161a2722bb09fed25.tar.gz
Add support for Vary
Diffstat (limited to 'requests_cache/session.py')
-rw-r--r--requests_cache/session.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/requests_cache/session.py b/requests_cache/session.py
index b65da1e..f3dec60 100644
--- a/requests_cache/session.py
+++ b/requests_cache/session.py
@@ -192,7 +192,16 @@ class CacheMixin(MIXIN_BASE):
cached_response: Optional[CachedResponse] = None
if not actions.skip_read:
cached_response = self.cache.get_response(actions.cache_key)
- actions.update_from_cached_response(cached_response)
+ actions.update_from_cached_response(cached_response, self.cache.create_key, **kwargs)
+
+ # TODO: Does this fit better here, or in CacheActions?
+ # If response contains Vary, check that the specified request headers match
+ # if cached_response and cached_response.headers.get('Vary'):
+ # vary = cached_response.headers['Vary']
+ # new_cache_key = self.cache.create_key(request, match_headers=vary)
+ # vary_cache_key = self.cache.create_key(cached_response.request, match_headers=vary)
+ # if new_cache_key != vary_cache_key:
+ # cached_response = None
# Handle missing and expired responses based on settings and headers
if actions.error_504: