# Progressive Web Apps and Service Workers

> Make web apps installable and offline-capable with a manifest and service worker caching, and re-engage users with push notifications. Free notes, key...

Canonical: https://www.internhack.in/roadmaps/tracks/frontend/pwa
Last updated: 2026-11-28

Make web apps installable and offline-capable with a manifest and service worker caching, and re-engage users with push notifications.

Advanced · about 6 hours · difficulty 4/5

Learn first: [Client-Side Storage](https://www.internhack.in/roadmaps/tracks/frontend/web-storage), [HTTP Caching, Compression and CDNs](https://www.internhack.in/roadmaps/tracks/frontend/caching)

A **Progressive Web App (PWA)** is a website that can be installed to the home screen or desktop, launch in its own window, work offline or on flaky networks and send notifications, all from one codebase.

### The building blocks

- **HTTPS** (required).
- A **web app manifest** (`manifest.webmanifest`): name, icons, theme colour, `start_url` and `display: "standalone"`. This makes the app installable.
- A **service worker**: a script that runs in the background, separate from pages, and can intercept network requests from your origin.

### Service worker lifecycle

Register it from your page; it goes through **install** (pre-cache core assets), **waiting** and **activate** (clean old caches). A new version waits until all tabs using the old one close, unless you prompt the user to update and call `skipWaiting`. Getting updates wrong is the most common PWA bug, so plan the update flow.

### Caching strategies

- **Cache first** for hashed static assets.
- **Network first** for HTML and API data that should be fresh, falling back to cache offline.
- **Stale-while-revalidate** for things like avatars and non-critical data.
- An **offline fallback page** for navigation requests.

**Workbox**, or `vite-plugin-pwa` which uses it, generates most of this for you.

### Notifications and more

The **Notifications API** shows system notifications after the user grants permission; the **Push API** lets a server wake the service worker to show one even when the site is closed (iOS supports this for installed web apps). Ask for permission in response to a user action with a clear reason, never on page load. **Background Sync** can retry failed requests when connectivity returns (limited browser support).

### Good enough to move on

You can turn an app into an installable PWA with an offline fallback, sensible caching strategies, a working update prompt and an opt-in notification.

## Key concepts

- **Web app manifest and installability**
- **Service worker registration and lifecycle**
- **Caching strategies**
- **Offline fallback pages**
- **Update flow and skipWaiting**
- **Workbox and vite-plugin-pwa**
- **Notifications and Push API**
- **Background Sync**

## Mini project

Turn your notes or expense app into a PWA with vite-plugin-pwa: installable, works offline with cached data, shows an 'update available' prompt and sends a reminder notification after the user opts in.

## Check yourself

You deployed a fix but users keep seeing the old version of your PWA. What part of the service worker lifecycle explains this?

## Free resources

- [Learn PWA](https://web.dev/learn/pwa) (web.dev)
- [Service Worker API](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) (MDN)
- [Workbox](https://developer.chrome.com/docs/workbox) (Chrome for Developers)

Previous: [Web Workers and Observer APIs](https://www.internhack.in/roadmaps/tracks/frontend/web-workers) · Next: [Real-Time Communication: WebSockets and SSE](https://www.internhack.in/roadmaps/tracks/frontend/realtime)

## More in Browser APIs and Progressive Web Apps

- [Client-Side Storage](https://www.internhack.in/roadmaps/tracks/frontend/web-storage)
- [Web Workers and Observer APIs](https://www.internhack.in/roadmaps/tracks/frontend/web-workers)
- [Progressive Web Apps and Service Workers](https://www.internhack.in/roadmaps/tracks/frontend/pwa)
- [Real-Time Communication: WebSockets and SSE](https://www.internhack.in/roadmaps/tracks/frontend/realtime)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Frontend Developer Roadmap](https://www.internhack.in/roadmaps/tracks/frontend)
