Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get service worker id or date from within service worker

Does anybody know if there is a way to get this number or date inside the service worker:

chrome debug tools screenshot of service worker info

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.

like image 251
Alex028502 Avatar asked Sep 19 '25 20:09

Alex028502


1 Answers

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().

like image 115
NOtherDev Avatar answered Sep 23 '25 11:09

NOtherDev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!