@@ -280,7 +280,7 @@ def cache_response(self, request, response, body=None, status_codes=None):
280280 cc = self .parse_cache_control (response_headers )
281281
282282 cache_url = self .cache_url (request .url )
283- logger .debug ('Updating cache with response from "%s"' , cache_url )
283+ logger .debug ('Updating cache %r with response from "%s"' , self . cache , cache_url )
284284
285285 # Delete it from the cache if we happen to have it stored there
286286 no_store = False
@@ -321,7 +321,10 @@ def cache_response(self, request, response, body=None, status_codes=None):
321321 # Add to the cache if the response headers demand it. If there
322322 # is no date header then we can't do anything about expiring
323323 # the cache.
324- elif "date" in response_headers :
324+ elif "date" not in response_headers :
325+ logger .debug ("No date header, expiration cannot be set." )
326+ return
327+ else :
325328 # cache when there is a max-age > 0
326329 if "max-age" in cc and cc ["max-age" ] > 0 :
327330 logger .debug ("Caching b/c date exists and max-age > 0" )
@@ -337,6 +340,8 @@ def cache_response(self, request, response, body=None, status_codes=None):
337340 self .cache .set (
338341 cache_url , self .serializer .dumps (request , response , body = body )
339342 )
343+ else :
344+ logger .debug ("No combination of headers to cache." )
340345
341346 def update_cached_response (self , request , response ):
342347 """On a 304 we will get a new set of headers that we want to
0 commit comments