I am using the new CacheStorage api and want to have a little job that cleans up old cached entries that are above a certain ttl (time to live).
In Chrome Dev Tools -> Application tab I see a 'Cached-Time' column but there is no way to retrieve this via the api.
const cache = await caches.open(`my-cache`);
const response = await cache.match(new Request(`https://someurl`))
console(response.cachedTime) <- // doesn't exist
I tried getting it via the Date header, but that only works for non-cors requests. The devtools somehow keeps track of all requests. Is there a way to get this information dyanamically via the CacheStorage api ?
// this is not a bullet proof method
// doesn't work for cors or if response doesn't send a Date header
console.log(response.headers.get(`date`));
Tried dumping the entire response and inspecting it but I didn't see anything useful.