From the course: JavaScript: Service Workers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Update the service worker

Update the service worker - JavaScript Tutorial

From the course: JavaScript: Service Workers

Start my 1-month free trial

Update the service worker

- [Instructor] After we have registered the Service Worker, in the future we usually want to change it with new code, so we need to think about this for a minute. When the Service Worker is going to be updated because the Service Worker is installed in users' devices. It works when the user is offline. So, the browser has a checking algorithm that is basically a byte-by-byte comparison in the service worker file. Some browsers are also making that byte-by-byte comparison in all the scripts used by ImportScripts. We can force an update from develop tools and also the browser will fire automatically that algorithm at some points but it can also be fired by an API, for example, we can have a user interface with an update button that will force the browser to make the check at that point. The API is pretty simple. When we have the registration object, we just call update and that will force the browser to try to go and run the checking algorithm. So, the algorithm is different per browser…

Contents