@@ -280,7 +280,7 @@ def cache_response(self, request, response, body=None, status_codes=None):
280
280
cc = self .parse_cache_control (response_headers )
281
281
282
282
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 )
284
284
285
285
# Delete it from the cache if we happen to have it stored there
286
286
no_store = False
@@ -321,7 +321,10 @@ def cache_response(self, request, response, body=None, status_codes=None):
321
321
# Add to the cache if the response headers demand it. If there
322
322
# is no date header then we can't do anything about expiring
323
323
# 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 :
325
328
# cache when there is a max-age > 0
326
329
if "max-age" in cc and cc ["max-age" ] > 0 :
327
330
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):
337
340
self .cache .set (
338
341
cache_url , self .serializer .dumps (request , response , body = body )
339
342
)
343
+ else :
344
+ logger .debug ("No combination of headers to cache." )
340
345
341
346
def update_cached_response (self , request , response ):
342
347
"""On a 304 we will get a new set of headers that we want to
0 commit comments