Help centre

Answer

What is Workbox?

Short answer

Workbox is a collection of open-source JavaScript libraries, maintained by Google, that wraps common service-worker patterns — precaching, runtime caching strategies, background sync, expiration — behind a simple API, so developers do not have to hand-write low-level Cache Storage and fetch-event logic.

By InstantPWA engineering·Reviewed July 25, 2026

What it provides

Precaching (workbox-precaching), routing (workbox-routing), and ready-made strategies like CacheFirst, NetworkFirst and StaleWhileRevalidate.

How it is used

Most build tools (Vite PWA plugin, Create React App, Angular Service Worker) generate a service worker using Workbox under the hood rather than requiring hand-written caching code.

When to write your own

For very simple caching needs, a hand-written service worker of a few dozen lines is often enough and avoids the extra bundle size.

Related
Do PWAs work offline?
PWAs can work offline, but only for content their service worker has explicitly cached. Registering a service worker does not automatically make a site offline-capable — you decide what to cache (app shell, API responses, images) and what strategy to use (cache-first, network-first, stale-while-revalidate).
What is the difference between cache-first and network-first caching?
Cache-first checks the cache first and only goes to the network if there is no cached match — best for static assets like fonts and logos that rarely change. Network-first always tries the network first and falls back to the cache only if the request fails — best for content that should be as fresh as possible, like an API response, while still working offline.
What icon sizes does a PWA need?
A PWA manifest needs at least a 192x192 and a 512x512 icon to be installable on Chromium browsers. For best results across platforms, also include a maskable icon (so Android does not crop your logo oddly) and a separate 180x180 apple-touch-icon link for iOS Safari, which does not read the manifest for its home-screen icon.
Does a PWA need HTTPS?
Yes, a PWA needs HTTPS. Browsers refuse to register a service worker on a plain HTTP origin because it can intercept and modify every network request, which would be a serious security risk over an unencrypted connection. The only exception is localhost and 127.0.0.1, which browsers treat as a secure context for local development.
What is the service worker lifecycle?
A service worker moves through four stages: install (fired once when the browser first downloads a new or changed worker), waiting (if an old version still controls open tabs), activate (once it takes control, typically after all old tabs close or skipWaiting() is called) and idle, where the browser terminates it between events to save memory.