Use a no-op Service Worker in Development

Share this video with your friends

Send Tweet

Having to manually unregister the Service Worker and clean the cache after you finish testing a Service Worker is ok, but at some point you’d rather automate it.

ServiceWorkerRegistration.unregister() can only be used within a registration and it doesn’t clean the cache, making it useless for the case.

However, using a no-operation (no-op) service worker will override the already registered one and remove the cache, leaving it in a clean slate.

The lesson shows how to automated this by creating a no-op Service Worker to use on development.