2016/Brighton/serviceworkers

From IndieWeb

Service Workers Use Cases was a session at IndieWebCamp Brighton 2016.

Notes archived from: https://etherpad.indieweb.org/serviceworkers


IndieWebCamp Brighton 2016 Session: service worker use cases

Participants

  • Jeremy Keith
  • Glenn Jones
  • Andrea Rota
  • Sven Knebel
  • Sebastian Lasse
  • Martin Tomes
  • Erik Erskine

Notes

  • basics: can intercept and handle failures for HTTP access to resources on a page
  • require HTTPS
  • installed via JS

adactio:

  • caches index pages -> offline readable

no magic, everything has to (but can be) implemented as desired using relevant APIs:

  • Cache API (intercept requests, store/fetch results to/from cache)
  • BackgroundSync API allows to schedule requests for later https://github.com/WICG/BackgroundSync/blob/master/explainer.md
  • notifications API (also allows notifications when the browser is closed)
  • postMessage API (send message between tabs and service worker)

use cases (easy -> complex):

  1. cache assets
  2. custom offline page
  3. cache first, then update
  4. network first -> start timer, if network to slow use cache
  5. allow user to store individual sites in local cache (e.g. read later)
  6. cached shell available: service worker can mark requests and only fetch partials and build them together