Sign up FAST! Login

Making A Service Worker: A Case Study

Stashed in: Web Development

To save this post, select a stash from drop-down menu or type in a new one:

Solid practical introduction to the Service Worker API, which basically lets you set a UX for your stuff when it's offline.

Cool. Today I learned what a Service Worker is:

A service worker is a script that stands between your website and the network, giving you, among other things, the ability to intercept network requests and respond to them in different ways.

In order for your website or app to work, the browser fetches its assets — such as HTML pages, JavaScript, images, fonts. In the past, the management of this was chiefly the browser’s prerogative. If the browser couldn’t access the network, you would probably see its “Hey, you’re offline” message. There were techniques you could use to encourage the local caching of assets, but the browser often had the last say.

This wasn’t such a great experience for users who were offline, and it left web developers with little control over browser caching.

You May Also Like: