A warehouse counting screen, a field service form, a checklist filled in on a construction site: these apps have to work where the connection comes and goes. The signal drops between the shelves, the technician is in the basement switch room, the form is left half-finished. A Progressive Web App (PWA) offers an app that can be built from the same web codebase, opens offline and needs no app store distribution. Below, with code examples, we explain when a PWA is the right choice in corporate scenarios, its limits compared with a native app, and how to set up the service worker, IndexedDB and update management.
When a PWA makes sense
Technically, a PWA has three parts: a web application served over HTTPS, a web app manifest file defining the app’s name, icons and start URL, and a service worker that can intercept network requests and respond from the cache. This trio lets the app be added to the home screen, open in its own window and open even without a network.
The scenarios where PWAs fit best on the corporate side:
- Data collection on an intermittent connection: Field and warehouse apps such as field service records, warehouse counts and inspection forms. The user fills in the form, the record is queued on the device and goes to the server when the connection comes back.
- A mixed device fleet: If the same app will run on Windows laptops, Android handheld terminals and iPads, a single codebase reduces the maintenance load.
- Internal tools with frequent releases: There’s no waiting for store approval; putting the new version on the server is enough for an update.
If continuous background location tracking, intensive Bluetooth/serial port communication, deep integration with device management or reliable background operation on iOS is needed, the picture changes. There a native or hybrid app produces fewer surprises.
PWA vs native app comparison
| Topic | PWA | Native app |
|---|---|---|
| Distribution | URL, install from the browser, forced install by policy in Chromium | App store or MDM |
| Updates | Publish to the server; the service worker downloads the new version | Store approval and a user/MDM update |
| Offline operation | Strong with service worker + IndexedDB | Full control |
| Background sync | Background Sync only in Chromium | Possible with platform APIs |
| Push notifications | In most browsers; on iOS in an app added to the home screen | Full support |
| Hardware access | Camera and location are widespread; Web Bluetooth, Web NFC and Web Serial in limited browsers | Full access |
Barcode scanning comes up in every project. Handheld terminal scanners working in keyboard wedge mode write the scanned code into a text field as keyboard input; this works seamlessly with a PWA. Scanning with the camera can be done via getUserMedia with a JavaScript library. The browser’s built-in BarcodeDetector API isn’t available on every platform. Don’t rely on it alone.
Service worker caching strategies
A service worker is a script running in a thread independent of the page that intercepts all network requests within its scope with the fetch event. A separate strategy is chosen for each resource type:
| Strategy | Behavior | Suitable resource |
|---|---|---|
| Cache first | From the cache if present, otherwise from the network | Version-hashed JS/CSS, fonts, icons |
| Network first | Try the network, fall back to the cache on failure | The HTML shell, frequently changing reference lists |
| Stale-while-revalidate | Serve from the cache immediately, update in the background | Data that can be slightly stale, such as product/warehouse lists |
| Network only | Always the network | Authentication, payments, write requests |
// sw.js
const VERSION = 'v2026-11-10';
const SHELL = `shell-${VERSION}`;
const SHELL_FILES = ['/', '/offline.html', '/app.css', '/app.js', '/manifest.webmanifest'];
self.addEventListener('install', (event) => {
event.waitUntil(caches.open(SHELL).then((c) => c.addAll(SHELL_FILES)));
});
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys().then((keys) =>
Promise.all(keys.filter((k) => k !== SHELL).map((k) => caches.delete(k)))
)
);
});
self.addEventListener('fetch', (event) => {
const request = event.request;
if (request.method !== 'GET' || new URL(request.url).pathname.startsWith('/api/')) return;
if (request.mode === 'navigate') {
event.respondWith(fetch(request).catch(() => caches.match('/offline.html')));
return;
}
event.respondWith(caches.match(request).then((res) => res || fetch(request)));
});
The example was deliberately kept simple. In production, using Google’s Workbox library for route-based strategy definitions, cache size/age limits and automatic generation of the cache list from the build output narrows the error surface. In a corporate app there are two more rules: don’t put user-specific API responses in Cache Storage on shared devices; clear the app’s caches and IndexedDB data on sign-out. A second user who picks up the same handheld terminal at a shift change mustn’t see the first user’s data.
Offline data and the sync queue
Cache Storage is for request/response pairs; the business data the user enters lives in IndexedDB. The pattern we recommend is an “outbox” queue: each record is written to the queue with a client ID, the interface immediately shows it as “pending”, and when the connection comes back the queue is sent in order.
import { openDB } from 'idb';
const dbPromise = openDB('field-app', 1, {
upgrade(db) { db.createObjectStore('outbox', { keyPath: 'id' }); },
});
export async function addToQueue(record) {
const db = await dbPromise;
await db.put('outbox', { id: crypto.randomUUID(), created: Date.now(), record });
}
export async function sendQueue() {
const db = await dbPromise;
for (const item of await db.getAll('outbox')) {
const response = await fetch('/api/service-records', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Idempotency-Key': item.id },
body: JSON.stringify(item.record),
});
if (response.ok || response.status === 409) await db.delete('outbox', item.id);
else if (response.status === 401) break; // the user must sign in again first
}
}
window.addEventListener('online', () => sendQueue());
The backbone of this code is the Idempotency-Key header (a widely used header being standardized as a draft at the IETF). On a mobile network, the request reaches the server and the response gets lost on the way; the client sends the same record again. The server must recognize the key and not create a second record. The key is stored on the server side in a column with a UNIQUE constraint. If this isn’t done, duplicate work orders come in from the field.
The Background Sync API (registration.sync.register()) lets the queue be sent even while the page is closed in Chromium-based browsers; it doesn’t exist in Safari and Firefox. Don’t base the design on it; use it as an enhancement: have the queue also processed at app startup, on the online event and when the user says “Send now”.
Write the conflict rule from the very start. If two technicians updated the same work order while offline, which one wins? In simple cases, it’s enough for the server to check a version number (version or ETag) and show the user a diff screen on conflict. If the last writer silently wins, data is lost. The form validation article explains how to share consistent validation rules between client and server.
Version updates and cache cleanup
The service worker lifecycle can surprise you during updates. When the browser finds a new sw.js, it installs it; but as long as tabs controlled by the old version are open, the new version stays in the waiting state. If the app on a handheld terminal is never closed, the new version doesn’t take effect for days. This is usually the source of the complaint “we released the fix but the old screen is still there in the field”. The recommended flow in corporate apps:
- The page detects the waiting new version through
registration.waitingor theupdatefoundevent. - A “New version ready, refresh” notification is shown to the user; no forced reload is done in the middle of a form.
- When the user confirms, the page sends a message to the waiting worker, and the worker calls
self.skipWaiting(). - The page reloads once on the
controllerchangeevent.
// page side
navigator.serviceWorker.addEventListener('controllerchange', () => location.reload());
// when the user clicks "Refresh":
registration.waiting?.postMessage({ type: 'SKIP_WAITING' });
// sw.js side
self.addEventListener('message', (e) => {
if (e.data?.type === 'SKIP_WAITING') self.skipWaiting();
});
On the server side, the sw.js and manifest.webmanifest files should be served with Cache-Control: no-cache; version-hashed static files, on the other hand, should be cached long-term as immutable. The details of CDN and browser cache headers are in the Cache-Control headers guide. When the version changes, delete old caches in the activate event; if they aren’t deleted, the storage quota on the device fills up.
Platform restrictions and checklist
Platform behavior changes with browser versions. Make the final decision with a pilot on the target devices. The main known restrictions:
- iOS/iPadOS: Installation isn’t done with an automatic prompt but with “Add to Home Screen” in Safari’s Share menu. Web push works in 16.4 and later only in apps added to the home screen. There’s no Background Sync.
- Storage: Browsers can delete site data under storage pressure or according to their own policies. Persistence can be requested with
navigator.storage.persist(); the result isn’t guaranteed. - Install prompt: The
beforeinstallpromptevent is specific to Chromium; in other browsers, explain the installation instructions separately in the interface. - Central deployment: In Chrome and Edge, forced installation on managed devices is possible with the
WebAppInstallForceListpolicy; on iOS/iPadOS, web clip distribution with MDM is possible but its behavior must be verified with a pilot.
Pre-release checklist:
- The entire app is served over HTTPS with a valid certificate.
name,short_name,start_url,displayand 192/512-pixel icons are defined in the manifest.- The service worker scope is correct; API and authentication requests aren’t cached.
- There’s a meaningful screen on offline startup; no blank white page.
- The outbox uses an idempotency key; the number of pending records is visible in the interface.
- Caches and IndexedDB are cleared on sign-out.
- The update flow has been tested;
sw.jsisn’t cached for long. - Scenarios in airplane mode, on a weak network and with a tab open for days were tried on the target devices.
A PWA that passes testing at a desk can get stuck at the first weak signal in the field. Don’t skip the last item. If the app’s server-side architecture is still being designed, the Server and Client Components in the Next.js App Router article explains the structure the offline layer will sit on. When designing your field and warehouse apps as PWAs, we can prepare the pilot and deployment plan together within the scope of our PWA and mobile web applications service. For conceptual reference, the web.dev PWA course and MDN Service Worker API pages are the primary sources.
Frequently asked questions
Do PWAs work on iOS devices?
Service workers, caching and IndexedDB work in Safari. Adding to the home screen is done by the user from the Share menu; web push notifications are supported from iOS/iPadOS 16.4 only in web apps added to the home screen. Some APIs, such as the Background Sync API, aren’t available in Safari. Design for the most restricted target platform.
Can data saved offline be lost?
Yes, it can. The browser can delete site data under storage pressure or according to its own policies. Persistent storage can be requested with navigator.storage.persist(), but the browser may refuse. Send queued records the moment a connection is available, show the user the number of pending records and don’t keep important data only on the device for long.
Can we deploy a PWA centrally to company devices?
In Chromium-based browsers, yes: Google Chrome and Microsoft Edge can force-install specified web apps on managed devices with the WebAppInstallForceList policy. The policy is distributed via Group Policy or MDM. On iOS/iPadOS, a web clip can be distributed to the home screen with MDM; verify with a pilot on the target iOS version that it behaves the same as a manually added PWA (storage, push, full screen).
How do we recover the app if the service worker publishes a faulty version?
The browser regularly checks the service worker file on the server for updates; the first remedy is to publish a corrected sw.js. If the situation is serious, a “self-destructing” service worker is published that deletes caches and removes its own registration with unregister. For this intervention to spread quickly, the sw.js file shouldn’t be held in the HTTP cache for long.