@@ -284,7 +284,7 @@ def cache_response(self, request, response, body=None, status_codes=None):
284
284
cc = self .parse_cache_control (response_headers )
285
285
286
286
cache_url = self .cache_url (request .url )
287
- logger .debug ('Updating cache with response from "%s"' , cache_url )
287
+ logger .debug ('Updating cache %r with response from "%s"' , self . cache , cache_url )
288
288
289
289
# Delete it from the cache if we happen to have it stored there
290
290
no_store = False
@@ -325,7 +325,10 @@ def cache_response(self, request, response, body=None, status_codes=None):
325
325
# Add to the cache if the response headers demand it. If there
326
326
# is no date header then we can't do anything about expiring
327
327
# the cache.
328
- elif "date" in response_headers :
328
+ elif "date" not in response_headers :
329
+ logger .debug ("No date header, expiration cannot be set." )
330
+ return
331
+ else :
329
332
# cache when there is a max-age > 0
330
333
if "max-age" in cc and cc ["max-age" ] > 0 :
331
334
logger .debug ("Caching b/c date exists and max-age > 0" )
@@ -341,6 +344,8 @@ def cache_response(self, request, response, body=None, status_codes=None):
341
344
self .cache .set (
342
345
cache_url , self .serializer .dumps (request , response , body )
343
346
)
347
+ else :
348
+ logger .debug ("No combination of headers to cache." )
344
349
345
350
def update_cached_response (self , request , response ):
346
351
"""On a 304 we will get a new set of headers that we want to
0 commit comments