What is a service worker ?

Browser

About

A service worker is a type of worker (JavaScript application) installed in the browser that can act as a forward proxy.

Two Ways

Browser > Server

They can:


Service Worker Responds Http Request

Server > Browser

They can receive http requests (and associated resources) created by the server


Service Worker Modifies Http Request Response

Usage

They make the following feature possible in the browser:

  • cache (useful when the network is not available)
  • push notifications,
  • background syncing,
  • offline functionality

Cache

This section explains the http cache feature.

The first time a user visits your page using a browser that supports service worker, all of the resources needed to use the page offline can be automatically cached locally, and each subsequent visit to any page on the site will be:

  • a) fast (since there's no network dependency)
  • b) work offline (for the same reason).

Management

The service worker needs to be registered (associated with) against:

Tool

Workbox

sw-toolbox and sw-precache are deprecated in favor of Workbox.

Test

Documentation / Reference





Discover More
Browser
Browser - Custom cache

If the default HTTP browser cache mechanism is not sufficient, you may implement your own cache system on top of fetching library with service worker.
Browser
Browser - Worker (Javascript)

Web Workers makes it possible to run a script operation in a background thread separate from the main execution thread of a web application. They are part of the web api (ie browser api) Same as workers...
Windows Internet Properties Proxy
HTTP - Forward Proxy

A forward proxy is a proxy application that is configured to intercept and forward every internal Http request to an destination website, hence the name Forward Proxy. It's also known as man-in-the-middle...



Share this page:
Follow us:
Task Runner