Service Workers by Dave Geddes

🚀 Service Workers

Hero Image

👨‍💻 By Dave Geddes


To register as a Service Worker with the js file - navigator.serviceWorker.register("/game/kolohe.js")

Four stages of Service Worker

  • Install
  • Wait
  • Activate
  • Terminate

Once the Service Worker is installed in the browser, it cannot be updated when the same site’s Service Worker code is updated

A new Service Worker is created for the new code.

When a new service worker is created, it will be in the “waiting phase” as the active service worker will still be active.

When you edit the service worker code with new line of code, service worker will terminate the new waiting service worker and creates a new waiting service worker.

Simple refresh cannot affect the active service worker.

Now with the new code, closing the internet will terminate the active service worker and waiting service worker will become active and stopped.

🌹 Extra Read

Service workers and the Cache Storage API

Service worker

It’s still recommended that you configure the Cache-Control headers on your web server, even when you know that you’re using the Cache Storage API. You can usually get away with setting Cache-Control: no-cache for unversioned URLs, and/or Cache-Control: max-age=31536000 for URLs that contain versioning information, like hashes.

Service Worker Overview

Access the service Workers using Chrome Internal - chrome://serviceworker-internals/ & chrome://inspect/#service-workers

Access the service Workers using Firefox Internal - about:debugging#/runtime/this-firefox

More Service Worker Resources

Share on Twitter
Share on Facebook

Created by Navin. He loves to learn, blog and develop new applications.
Twitter LogoGithub LogoLinkedIn LogoFaceBook Logo