Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List chromes registered service workers

Tags:

Is there a way to list all the browsers registered service-workers? Lets say that I have registered/installed a few service workers. can I get a list an array of the file names via js?

like image 873
Shai Kimchi Avatar asked Mar 30 '16 10:03

Shai Kimchi


2 Answers

Apparently I have found two ways that works fine for me (for chrome): one is using shortcut command:

chrome://serviceworker-internals/

Other one is:

go to Developers Tool -> Resources -> Service Workers

like image 53
Saugat Bhattarai Avatar answered Sep 29 '22 13:09

Saugat Bhattarai


There isn't a way to get "all the browser's" registered service workers programmatically from a web page, since a web page can only access the service workers that are registered for its scope. But if you're looking for a way to get those, then call navigator.serviceWorker.getRegistrations to get a promise that resolves to an array of registered service workers:

navigator.serviceWorker.getRegistrations().then(function(registrations) {
  registrations.forEach(function(v) { console.log('service worker: ' + v) });
});
like image 31
Myk Melez Avatar answered Sep 29 '22 13:09

Myk Melez