I am trying to access the response header "date" from one of my cached elements.
As you can see in the picture, my request does not return the correct timestamp. Instead, it returns null, and I don't know why.
Here is the code I use:
var cachedFile = "https://www.washingtonpost.com/resizer/rgjyoeu2BaoUyNiojHCKLjN9udM=/1484x0/arc-anglerfish-washpost-prod-washpost.s3.amazonaws.com/public/EXKAUXTXXUI6TJ57ZCSDXBHOGE.jpg";
caches.open("dynamic-content").then(cache => {
cache.match(cachedFile).then(response => {
if(! response){
console.log("not found");
}else{
var element = response.headers.get('date');
console.log(element);
}
})
})
My goal is to delete old cached files. Without using workbox or any plugins. If someone knows a way, I'm happy to be enlightened ;)

response.headers.get('Date'). If it still not working, you can tryconsole.log(response.headers)to see what is inside the header object.