DEV Community


Discussion on: Let Users Know When You Have Updated Your Service Workers in Create React App

tomas223 profile image
Tomas Hornak • Edited

Great article. It helped me finally understand serviceWorkers.

After some more digging I started to wonder if it wouldn't be better to avoid storing ServiceWorkerRegistration and retrieve one when needed.
Should I concern that object can "expire" after some longer time?

I came to this:

if ('serviceWorker' in navigator) {
    navigator.serviceWorker.ready.then(registration => {
        const registrationWaiting = serviceWorkerRegistration?.waiting;
glukmann profile image
Gert Glükmann Author

Well yeah, when user doesn't click the Update button then maybe should think about the "expiring". Should test it out. Retriving it when needed probably would be safer solution?

tomas223 profile image
Tomas Hornak

I will use your example for now and will see in future if there are any issues with it. If yes I will come back to report it :)

Forem Open with the Forem app