Reputation: 3814
Does anybody know if there is a way to get this number or date inside the service worker:
It would be handy to name my service worker cache either cache-1182
or cache-20171127171448
I guess the received date must be known before the install event.
Upvotes: 4
Views: 1829
Reputation: 9672
No, this thing does not exist in the Service Worker specs so we must assume it is an internal implementation detail of Google Chrome, thus unaccessible.
To simplify, you might use installation timestamp as the version number and then look for cached resources in the cache marked with the newest timestamp. You can inspect all the cache keys with caches.keys()
.
Upvotes: 5