Skip to content
micro-frontend.dev 2.0

Micro-frontends and Service Workers

Author: Natalia Venditto

Date First Published: Wed Jan 04 2023

What are service workers?

Service Workers are a great capability to implement progressive enhancement, out of the box and from the get go: if a user visits a site implementing service workers with a browser that doesn’t support them, no functionality will be be lost, and nothing will break.

How do service workers work?

Service workers are a complex piece of technology and I can’t condense all they do in a simple paragraph. The idea is to extend this site with practical examples and even challenges to get started with technologies, but for now, let’s just say that service workers are a technology that runs in its own thread*, has its own lifecycle, and it’s built to intercept network requests and responses, and cache them, so they can be served offline, or even when the network is slow or the connection goes intermitently offline and online.

service workers

This is also useful to compose micro frontends from cached data, since we can either precache -cache on install- or implement cache on demand, at runtime, caching data from network responses from other sources, or from browser storage, like IndexDB or localStorage.