Progressive Web Apps

Intermediate · 8 min

What makes a site installable and offline-capable — service workers, the web app manifest, and caching strategies explained.

Before thisWeb Performance & Core Web Vitals

Fireship · 8 min

Progressive Web Apps

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by FireshipReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • A Progressive Web App is an ordinary website that meets a specific bar — a manifest, HTTPS, and a service worker — that unlocks installability and offline behavior.
  • A service worker is a background script that sits between your app and the network and can intercept, cache, or fabricate responses to requests.
  • The web app manifest is a JSON file that tells the operating system how to treat the installed app — its icon, name, start URL, and display mode.
  • Caching strategies like cache-first and network-first trade off speed and offline support against freshness, and the right choice depends on the kind of data.
  • PWAs matter because they close the gap between 'just a website' and a native app without requiring an app-store release for every update.

The gap a PWA is built to close

For years, “do you want a website or an app?” was a real fork in the road, and each side had an obvious weakness. A website was instantly reachable by a link, worked on any device, and updated the moment you deployed — but it had no icon on the home screen, stopped working the second the network dropped, and felt like a page rather than a product. A native app had an icon, ran offline, and felt integrated into the device — but it demanded an app-store submission and review for every change, meant building and maintaining separate codebases for iOS and Android, and asked the user to accept an install before they’d even seen whether the thing was worth using.

A Progressive Web App is the industry’s answer to that trade-off: take an ordinary website, and progressively layer on the capabilities that used to require going native — installability, offline behavior, a real icon and splash screen — without leaving the web’s deployment model behind. “Progressive” is the key word: nothing about adding these capabilities breaks the plain website underneath. A browser that doesn’t support PWA features just shows the regular page; a browser that does support them unlocks the extra behavior. Nobody is excluded, and the enhancement is pure upside.

The three pieces that make it official

A website crosses from “just a website” to “an installable PWA” when three specific things are in place.

First, it has to be served over HTTPS. This isn’t optional security theater — a service worker has enough power to intercept and rewrite every network request the page makes, so browsers refuse to let that power exist over an insecure connection where it could be hijacked in transit.

Second, it needs a web app manifest — a small JSON file, linked from the HTML with <link rel="manifest" href="/manifest.json">, that describes how the app should behave once installed. It specifies the app’s name and short_name, the icons to show on a home screen or app drawer at various resolutions, the start_url to open when launched, and the display mode — standalone, for instance, hides the browser’s address bar and tab strip so the installed app looks and feels like a native window rather than a browser tab. None of this is configurable through ordinary HTML or CSS; it’s specifically what the manifest exists to control.

Third, and most consequential, it needs a registered service worker.

What a service worker actually is

A service worker is a JavaScript file that the browser runs in its own background thread, completely separate from your page’s main thread and even separate from any particular tab. Once registered — typically with navigator.serviceWorker.register('/sw.js') — it sits between your app and the network as a programmable proxy. Every time the page makes a request, the service worker gets a chance to intercept it through the fetch event: it can let the request go to the network as normal, serve a response straight from a cache without touching the network at all, or even construct a response from scratch.

This is the mechanism that makes offline support possible. Without a service worker, losing network connectivity means every request fails and the browser shows its own “no internet” page. With one in place, the service worker can notice the network request failed, reach into a cache it populated earlier, and hand back the cached version instead — the user sees the app functioning, possibly with slightly stale data, rather than a dead connection screen. The service worker also keeps running independently of whether the tab is open, which is what enables background sync and push notifications, though those build on top of the same core interception mechanism.

Choosing a caching strategy

Having the power to intercept every request doesn’t tell you what to actually do with that power — that choice is called a caching strategy, and different data deserves different strategies.

Cache-first checks the cache before ever touching the network, and only falls back to a real request if nothing cached exists. This is the right call for assets that almost never change — your app’s logo, a compiled CSS bundle with a content hash in its filename, icon fonts. These load instantly and cost zero bandwidth on repeat visits, and there’s nothing to lose by skipping a network round trip, because the content genuinely won’t have changed.

Network-first does the opposite: try the network, and only reach for the cache if the network request fails entirely, such as when the device is offline. This fits data where freshness matters more than speed — a live stock price, a news headline, an inbox count. Serving a week-old cached version of actively changing data would be actively misleading, so the strategy accepts a few extra milliseconds of latency in exchange for correctness whenever the network is actually available.

There are further variants — stale-while-revalidate serves the cached version immediately while quietly fetching a fresh one in the background for next time — but cache-first and network-first cover the two ends of the real trade-off: how much do you value speed and offline resilience versus how much do you value the response being perfectly current. Picking per resource, rather than one global policy for the whole app, is what separates a PWA that merely works offline from one that feels genuinely reliable.

Check yourself

  1. 01What three things does a website need to qualify as an installable Progressive Web App?

    It needs to be served over HTTPS, have a valid web app manifest describing how it should look and behave when installed, and register a service worker that controls at least a basic offline experience.

  2. 02What does a service worker actually do, mechanically?

    It's a JavaScript file that runs in its own background thread, separate from the page, and once registered it can intercept every network request the page makes through the `fetch` event, letting it serve a cached response, modify the request, or fabricate a response entirely, even when the device has no network connection.

  3. 03What does the web app manifest control that plain HTML and CSS can't?

    It tells the operating system how to treat the app once installed — the icon shown on the home screen, the name under that icon, the start URL to open, and the display mode, such as running in a standalone window without the browser's address bar — none of which a page can configure through markup or CSS alone.

  4. 04When would you choose a network-first caching strategy over cache-first, and why?

    Network-first fits data that changes often and where staleness is actively harmful, like a live price or a news feed, because it tries the network first and only falls back to the cache when offline, whereas cache-first fits assets like a logo or a CSS file that almost never change and benefit more from instant, bandwidth-free loading than from always re-fetching.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark