Skip to content

Commit db28caf

Browse files
committed
apply heuristics more aggresively
1 parent 4746b90 commit db28caf

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

cachecontrol/adapter.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ def build_response(self, request, response, from_cache=False):
5656
cached response
5757
"""
5858
if not from_cache and request.method == 'GET':
59+
# Check for any heuristics that might update headers
60+
# before trying to cache.
61+
if self.heuristic:
62+
response = self.heuristic.apply(response)
5963

6064
# apply any expiration heuristics
6165
if response.status == 304:
@@ -83,11 +87,6 @@ def build_response(self, request, response, from_cache=False):
8387
elif response.status == 301:
8488
self.controller.cache_response(request, response)
8589
else:
86-
# Check for any heuristics that might update headers
87-
# before trying to cache.
88-
if self.heuristic:
89-
response = self.heuristic.apply(response)
90-
9190
# Wrap the response file with a wrapper that will cache the
9291
# response when the stream has been consumed.
9392
response._fp = CallbackFileWrapper(

0 commit comments

Comments
 (0)