Section650

Writing

TopicWeb development
Reading6 min

Progressive Web Apps: Offline First, App Shell and What Works on iOS Today

Service workers, install and web push now work in every major browser, including Safari on iPhone with some catches. Here is what a PWA can do today, a minimal offline service worker, and when native or React Native is the better call.

By Ka Lun Chan · Web development / Architecture

Are progressive web apps still worth building?

Yes, for products that live on the web and need to load fast, work on a bad connection and sit on a home screen. The pieces I was excited about when I first wrote this now work in every major browser, including Safari. A PWA still isn’t a full replacement for a native app when you need deep device access or app store distribution.

I first wrote this on my old blog. This version keeps the ideas that held up and updates what changed, including Apple’s side of the story.

Back then I called the PWA the future of the web application, because it brought native app features to the mobile browser. That turned out half right. PWAs didn’t replace native apps, but the features I listed became normal web platform capabilities:

  • An app-like experience, launched from an icon without browser chrome
  • Offline first, so the app opens without a network
  • Add to home screen
  • Push notifications
  • Faster loads from a cached app shell
Fig. 637-1 PWA capabilities: what works today and the catch
CapabilitySupport todayThe catch
Offline and cachingService workers work in all major browsers, including Safari since iOS 11.3You own cache invalidation. A careless worker keeps serving old files.
Install to the home screenChromium browsers offer install when the criteria are met. iOS 16.4 and later installs from the Share menu.iOS has no install prompt, so users have to find the Share menu. MDN says desktop Firefox doesn’t install from a manifest.
Push notificationsChromium browsers and Firefox. iOS and iPadOS 16.4 and later for Home Screen web apps.On iPhone the user must install the app first, and permission has to come from a tap.
App shellAnywhere service workers runContent still loads on the client, so the first visit needs server rendering or streaming to feel fast.
Background syncLimited availability. MDN marks it as not Baseline.Feature-detect it and retry on the next launch where it’s missing.
Device APIs (Bluetooth, NFC, deep OS hooks)Uneven, often Chromium onlyIf the product depends on them, you probably need a native app.

What makes a web app a PWA?

A web app manifest, HTTPS and, for offline support, a service worker. The manifest tells the device the app’s name, icon and how to launch it. The service worker is the script that sits between the page and the network.

That’s the same definition I gave originally, and it still holds. The manifest is a small JSON file linked from your HTML with <link rel="manifest" href="/manifest.webmanifest">:

manifest.webmanifest
{
  "name": "Field Notes",
  "short_name": "Notes",
  "start_url": "/",
  "display": "standalone",
  "theme_color": "#1f2933",
  "background_color": "#ffffff",
  "icons": [
    { "src": "/icons/192.png", "sizes": "192x192", "type": "image/png" },
    { "src": "/icons/512.png", "sizes": "512x512", "type": "image/png" }
  ]
}

The display member matters more than it looks. On iPhone, WebKit says a site without standalone or fullscreen is saved as a bookmark that opens in the browser, and it doesn’t get web push.

I still like the app shell idea: cache the minimal HTML, CSS and JavaScript that draws the frame of the app, then fill in content. The web.dev architecture guide is honest about its limit. The shell comes from the single-page app world, where content loads on the client, so the first render waits on JavaScript. Streaming the shell and content together from the worker, or rendering on the server, fixes that. I cover the server side in server-side rendering React with Next.js.

How does a service worker make a site work offline?

The service worker intercepts the page’s network requests and decides whether to answer from a cache or the network. Precache the app shell when the worker installs, and the app opens offline. It only runs over HTTPS, or on localhost while you develop.

Registration is a few lines in the page:

Register the service worker
// main.js: register after load so the worker doesn't compete with the first render
if ('serviceWorker' in navigator) {
  window.addEventListener('load', () => {
    navigator.serviceWorker.register('/sw.js').catch((error) => {
      console.error('Service worker registration failed:', error);
    });
  });
}

The worker below precaches the shell, removes old caches when a new version activates and serves same-origin requests cache first, falling back to the network and then to an offline page:

A minimal cache-first service worker
// sw.js: precache the app shell, then serve same-origin GETs cache first
const CACHE = 'shell-v1';
const SHELL = ['/', '/app.css', '/app.js', '/offline.html'];

self.addEventListener('install', (event) => {
  event.waitUntil(caches.open(CACHE).then((cache) => cache.addAll(SHELL)));
});

self.addEventListener('activate', (event) => {
  // Delete caches from older versions of this worker
  event.waitUntil(
    caches.keys().then((keys) =>
      Promise.all(keys.filter((key) => key !== CACHE).map((key) => caches.delete(key)))
    )
  );
});

self.addEventListener('fetch', (event) => {
  const { request } = event;
  if (request.method !== 'GET' || new URL(request.url).origin !== self.location.origin) return;

  event.respondWith(
    caches.match(request).then((cached) => {
      if (cached) return cached;
      return fetch(request)
        .then((response) => {
          if (response.ok) {
            const copy = response.clone();
            event.waitUntil(caches.open(CACHE).then((cache) => cache.put(request, copy)));
          }
          return response;
        })
        .catch(async () => {
          const offline = request.mode === 'navigate' && (await caches.match('/offline.html'));
          return offline || Response.error();
        });
    })
  );
});

Cache first is right for versioned static files and wrong for HTML you update often, because users keep seeing the cached page until you ship a new worker. That’s the most common mistake I see with hand-written workers. The Workbox caching strategies guide lays out the options: cache first for CSS, JavaScript, images and fonts, network first for HTML and API calls, and stale-while-revalidate for things that can be slightly out of date. For anything beyond a demo, I’d use Workbox rather than maintain this logic by hand:

Per-request strategies with Workbox
// The same idea with Workbox: fresh HTML when online, cached assets always
import { registerRoute } from 'workbox-routing';
import { CacheFirst, NetworkFirst } from 'workbox-strategies';

registerRoute(({ request }) => request.mode === 'navigate', new NetworkFirst({ cacheName: 'pages' }));

registerRoute(
  ({ request }) => ['style', 'script', 'image', 'font'].includes(request.destination),
  new CacheFirst({ cacheName: 'assets' })
);

Did Apple end up supporting PWAs?

Mostly, yes. When I first wrote this, only Chrome, Firefox and Opera supported service workers, and I asked whether Apple would follow. Safari added service workers with iOS 11.3, and iOS 16.4 added web push for web apps installed to the Home Screen.

WebKit announced service worker support for iOS 11.3 and macOS High Sierra 10.13.4. The bigger change came later, with Web Push for Home Screen web apps on iOS and iPadOS 16.4, along with the Badging API. The conditions are specific:

  • Push works only after the user adds the web app to the Home Screen. A Safari tab can’t receive it.
  • The permission request has to follow a direct user action, such as tapping a subscribe button.
  • The manifest needs display set to standalone or fullscreen.

Installing is still the weak spot. MDN’s installability guide says iOS 16.4 and later install from the Share menu in Safari, Chrome, Edge, Firefox and Orion, and Safari 17 on macOS has Add to Dock. There’s no install prompt on iOS, so if your product depends on people installing it, you have to teach them where the Share menu is. Some APIs, such as background sync, still have limited availability, so feature-detect and plan a fallback.

What does it take to make a PWA installable?

In Chrome: HTTPS, a manifest with a name, 192px and 512px icons, a start URL and a standalone-style display mode, plus some user engagement. A service worker is no longer required just to install.

The current criteria also ask that the user has clicked or tapped the page and spent at least 30 seconds on it before Chrome promotes the install. Chrome dropped the fetch handler requirement in Chrome 108 on mobile and 112 on desktop, and Lighthouse removed its PWA category in the same move. So a green Lighthouse PWA badge is no longer something to chase. Use the Application panel in DevTools to debug the manifest and the worker, and test offline behavior yourself with the network turned off.

Installable and useful offline are now separate questions. I’d still ship a worker for any app people open repeatedly, because offline first is what makes the installed app feel like an app instead of a bookmark.

When is a PWA the right call instead of a native or React Native app?

Choose a PWA when the web is your main channel, search and shareable links matter, and the features you need are covered by the browser. Choose native or React Native when you need app store distribution, reliable push on every device without an install step, or deep device APIs.

A PWA wins on reach and cost. One codebase, instant updates with no store review, and every screen has a URL that search engines and people can link to. Content sites, internal tools, booking and ordering flows and field apps that need offline forms are good fits.

Native or React Native wins when the product lives on the phone. Users expect to find it in an app store, notifications have to reach people who never installed anything from a browser, or you need Bluetooth, background location or tight OS integration. If you want one codebase across iOS and Android in that case, I compare the options in React Native for cross-platform apps.

Plenty of teams do both: a PWA for the open web and a native app for the most engaged users. That works if the two share an API and you’re honest about the cost of maintaining two front ends.

Sources

Checked in November against WebKit’s announcements, MDN’s service worker, installability and background sync docs, web.dev’s install criteria and PWA architecture guide, Chrome’s installability update and Lighthouse release notes, the Workbox caching strategies guide and Google Search Central. The table, the code and the recommendations are mine.

Short answers

Do progressive web apps work on iPhone?

Yes. Safari has supported service workers since iOS 11.3, and iOS and iPadOS 16.4 added web push and app badges for web apps added to the Home Screen. Users install from the Share menu, because iOS has no install prompt, and push only works after the app is installed.

Does a PWA need a service worker to be installable?

Not in Chrome any more. Chrome dropped the fetch handler requirement in Chrome 108 on mobile and 112 on desktop. You still need HTTPS and a manifest with a name, 192px and 512px icons, a start URL and a standalone-style display mode. A service worker is still what makes the app work offline.

What caching strategy should a service worker use?

Use cache first for versioned static files such as CSS, JavaScript, images and fonts, network first for HTML and API calls, and stale-while-revalidate for content that can be slightly out of date. Workbox implements all of these.

Should I build a PWA or a native app?

Build a PWA when the web is your main channel, links and search matter and the browser covers the features you need. Choose native or React Native when you need app store distribution, push without an install step or deep device APIs such as Bluetooth or background location.

Start with the shell

Add a manifest, register a small worker that precaches your app shell, then turn the network off and open the app. Whatever breaks is your offline roadmap.

Tell me what you’re building