Reputation: 171
I'm using the JS CacheStorage API, I need to make sure that the cached request is up to date. How can I retrieve the cached time of the saved cache?
Upvotes: 2
Views: 2372
Reputation: 998
I cache the entire app all at once whenever a semver version changes. At the end of the caching sequence, this code fires to create a request for /time-cached
which I present on my dashboard for debugging purposes.
const cache = await caches.open(theVersion);
await cache.put('/time-cached', new Response( new Date() ));
Upvotes: 0
Reputation: 334
In your cache object, you can simply store the Date.now.
Note: I would post it as a comment but I don't have the reputation for that.
Upvotes: 2