Add service worker to your project

(use workbox )

Service Worker

  • Why
  • Real problem solved
  • What is it
  • How (JSer meeting)

Why

  • Faster response
    • Because it's from local cache.
  • Offline support:
    • There will be no down time even the user's network situation is bad.
  • Can limited the affected area.

Server

JS

CSS

IMG

html

Pre-cache

  • Build a pre-cache list for static assets.
  • Build a `sw.js`.
  • Pre-cached!

Problem: Exmaple

Server

a.hash-1.js

Server

a.hash-1.js

a.hash-2.js

Script Error

Server

a.hash-1.js

a.hash-2.js

Script Error

Service worker

Introduction to Workbox

By Denny Ku

Introduction to Workbox

  • 498