Business & Product
Progressive Web Apps and Offline-First Design for African Users
Connectivity in many markets is intermittent and data is expensive. Offline-first PWAs deliver app-like experiences that work on a bad day, with no app-store friction.
By Philip Mutuku · Published · Updated · 5 min read
Imagine a shopkeeper recording sales on a phone while the network drops every few minutes, or a field agent collecting survey data in an area with no signal at all. An app that shows a spinner and then an error is useless to them. Offline-first design starts from the opposite assumption: the network is a bonus, not a requirement.
What is a Progressive Web App?
A PWA is a website that uses modern browser features to behave like an installed app: it can be added to the home screen, launch full-screen, load instantly and work offline.[2] You build it with the same web technologies you already know and deploy it by publishing a website, with no app-store review or fees.
Three ingredients make it work:
- HTTPS, required for the powerful APIs involved.
- A web app manifest, a small JSON file giving the name, icons, colours and display mode, which enables installation.[4]
- A service worker, a script that sits between your page and the network, able to cache files and respond when offline.[3]
{
"name": "Duka Manager",
"short_name": "Duka",
"start_url": "/?source=pwa",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#0A1F4F",
"icons": [
{ "src": "/icons/icon-192.png", "sizes": "192x192", "type": "image/png" },
{ "src": "/icons/icon-512.png", "sizes": "512x512", "type": "image/png" }
]
}
Choose a caching strategy per resource
| Strategy | How it works | Good for |
|---|---|---|
| Cache first | Serve from cache; hit the network only if missing | Fonts, icons, versioned CSS and JS |
| Network first | Try the network; fall back to cache when offline | Frequently changing pages and API data |
| Stale-while-revalidate | Show cached copy immediately, refresh in the background | Product lists, feeds, profile data |
const CACHE = 'app-shell-v3';
const SHELL = ['/', '/offline.html', '/app.css', '/app.js'];
self.addEventListener('install', (event) => {
event.waitUntil(caches.open(CACHE).then((cache) => cache.addAll(SHELL)));
});
self.addEventListener('fetch', (event) => {
if (event.request.method !== 'GET') return;
event.respondWith(
caches.match(event.request).then((cached) => {
const fresh = fetch(event.request)
.then((response) => {
const copy = response.clone();
caches.open(CACHE).then((cache) => cache.put(event.request, copy));
return response;
})
.catch(() => cached || caches.match('/offline.html'));
return cached || fresh; // stale-while-revalidate
})
);
});
The harder part: offline data
Caching the interface is easy. The real engineering is data. Offline-first apps read and write to local storage (IndexedDB) first, and synchronise with the server when the connection returns.
- Write locally, immediately. The user’s action succeeds instantly and is placed in an outbox queue.
- Sync in the background. When the network is available, send queued changes in order.
- Make writes idempotent. Give each action a unique ID so a retried upload never creates duplicates.
- Handle conflicts deliberately. If two devices edit the same record offline, decide a rule: last write wins, merge fields, or ask the user.
- Show honest status. “Saved on this device. Will sync when online” builds trust; silent failure destroys it.
// Queue an action locally, then try to flush it.
async function recordSale(sale) {
const action = { id: crypto.randomUUID(), type: 'sale.create', payload: sale, at: Date.now() };
await localDb.outbox.add(action); // IndexedDB write: works offline
showToast('Saved. Will sync when online.');
flushOutbox();
}
async function flushOutbox() {
if (!navigator.onLine) return;
for (const action of await localDb.outbox.orderBy('at').toArray()) {
try {
await fetch('/api/actions', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Idempotency-Key': action.id },
body: JSON.stringify(action),
});
await localDb.outbox.delete(action.id);
} catch {
break; // still offline or server unreachable: keep the rest queued
}
}
}
window.addEventListener('online', flushOutbox);
Testing on the conditions your users actually have
An offline-first app that was only tested on fast Wi-Fi has not been tested. Use your browser’s developer tools to throttle the network to a slow mobile profile, switch to offline mode, and walk through every core journey. Then try the app on a genuine low-cost Android phone, because limited memory and a slower processor reveal problems a desktop never will.
- Load the app, go offline, and reload. Does it still open?
- Make a change offline, reconnect, and confirm it syncs once and only once.
- Interrupt a sync halfway. Is any data lost or duplicated?
- Fill the device storage and see how the app fails.
- Use Lighthouse for a baseline PWA and performance audit, but do not stop at a good score.
Syncing without losing or duplicating data
Offline edits need a plan for conflicts. Give every record a unique ID created on the device, queue changes locally with timestamps, and send them when the connection returns. On the server, make each write idempotent so that a retried request after a dropped connection does not create a second record. Decide up front how conflicts resolve: last write wins is simple, but for orders or stock you may need to merge or ask the user.
Installability and distribution
A PWA can be added to the home screen from the browser without an app store, which saves cost and removes review delays. To be installable, it needs HTTPS, a web app manifest with icons and a service worker. Remember that install prompts differ between browsers, so add short instructions for users who need to tap “Add to Home screen” themselves.
Security and privacy on shared devices
Offline-first means data lives on the device, and many devices in the field are shared or can be lost. Store only what the user needs offline, avoid keeping sensitive details such as full ID numbers or payment data in local storage, and clear data on sign-out. Serve everything over HTTPS, since service workers require it, and consider encrypting sensitive offline records and expiring them after a set period.
Handle updates with care as well. A stale service worker can keep serving an old version of your app for days. Provide a visible “New version available, refresh” prompt so users get fixes and security patches promptly.
Frequently asked questions
Can a PWA replace a native app?
For many business apps, such as forms, catalogues, bookings and dashboards, yes. If you need deep device access, heavy graphics or background processing, a native or cross-platform app may serve you better.
Does a PWA save mobile data?
It can. Cached assets are not downloaded again, and you control what is fetched. Compress images, avoid large libraries and let users choose when to download heavy content.
Respect expensive data
- Keep payloads small. Compress images, avoid shipping megabytes of JavaScript, and paginate API responses.
- Cache aggressively so repeat visits cost almost no data.
- Let users choose when to download large content, such as maps or catalogues, instead of doing it silently.
- Test on a throttled connection and a mid-range Android phone, not just your development laptop.
A PWA will not replace every native app, since deep hardware access and some platform features still favour native code. But for forms, catalogues, point-of-sale, field data collection and dashboards, an offline-first PWA reaches more people, on more devices, for less money.[1]
References & further reading
- web.dev, “Learn PWA” course: service workers, caching and installability. https://web.dev/learn/pwa
- MDN Web Docs, “Progressive web apps”. https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps
- MDN Web Docs, “Service Worker API” and “Cache API”. https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
- MDN Web Docs, “Web app manifest”. https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Manifest