Offline web apps

Hand-drawn sand, linen and umber wood-grain lines fill an irregular terracotta enclosure joined to two narrow, curving channels.

An offline web app is a web page that loads and keeps working without a network connection, using tools built into the browser. Two mechanisms do the work: a service worker, which stores the app’s files so they load offline, and browser storage, which holds the user’s data. The tools are large but revocable: browsers may delete stored data, and Safari deletes some of it after a week of disuse. Evidence for the speed benefit comes mostly from one site, and the closest evidence on offline failures comes from native Android apps.

Service workers

A service worker is a script that sits between a page and the network. It proxies the page’s requests and can answer them from the Cache API, so an app the user has visited before loads offline (MDN contributors, 2026c). An app can set itself up to use cached assets first and so give a default experience offline (MDN contributors, 2026c).

Its lifecycle has stages that surprise developers. A new version installs, then waits while the old version still controls open pages, and activates when those pages close or when the new worker calls skipWaiting() (MDN contributors, 2026c). The specification names six states: parsed, installing, installed, activating, activated and redundant (W3C Service Workers Working Group, 2026).

The first visit is not covered. A document keeps for its whole life the service-worker status it started with, so existing pages must reload to be controlled unless the worker claims them with clients.claim() (MDN contributors, 2026c).

Workers and caches follow different clocks. The specification advises that workers “may be started and killed many times a second”, so state must not live in memory (W3C Service Workers Working Group, 2026). Cache contents never expire unless the app deletes entries, and they are not updated unless the app asks (W3C Service Workers Working Group, 2026).

Progressive Web Apps and offline-first

A Progressive Web App (PWA) is, in MDN’s definition, an app built with web technology that gives an experience like a platform-specific app (MDN contributors, 2026a). One magazine article calls PWAs a delivery mechanism, not a data architecture (Pawar, 2026). A PWA can load offline without saying where the user’s data is primary. The local-first essay adds that PWA features such as service workers help offline support, which is often still fragile (Kleppmann et al., 2019).

Offline-first is a design aim rather than a technology. A 2017 master’s thesis defines it as a web development paradigm whose goal is usability independent of connection state, with offline as the default case (Twesten, 2017). In that thesis the apps keep offline updates in client storage. They merge them with server data once a connection exists (Twesten, 2017). Local-first software goes further and makes the device copy the primary one.

Browser storage

Browsers offer several places to keep data, including the origin private file system (OPFS), a file system private to the page’s origin (MDN contributors, 2026b). SQLite can also run in the browser, compiled to WebAssembly and storing its data through OPFS (SQLite Consortium, n.d.).

The SQLite options have limits. The OPFS-based file layer (a VFS) runs only in workers and needs special cross-origin headers (COOP/COEP) so that SharedArrayBuffer is available (SQLite Consortium, n.d.). A second layer, opfs-sahpool, needs no such headers but does not support several simultaneous connections to one database, except within one thread (SQLite Consortium, n.d.).

Quotas, persistence and eviction

Stored data is best-effort by default, so the browser may delete it. Under storage pressure, browsers evict data using a least-recently-used policy, and origins in persistent mode are exempt (MDN contributors, 2026b). The Storage Standard gives each storage bucket one of two modes, best-effort or persistent (van Kesteren, 2026). WebKit defines eviction as automatic deletion not started by the user or the website (Liu, 2023).

Quotas are large, but the browsers differ.

BrowserPer-origin quotaSource
ChromeUp to 60% of total disk, in both persistent and best-effort modes(MDN contributors, 2026b)
FirefoxBest-effort: the smaller of two limits, one being 10% of disk(MDN contributors, 2026b)
Safari (browser app)Up to 60% of total disk(Liu, 2023)

An app can ask for protection. persist() asks the user for permission and makes storage persistent once granted (van Kesteren, 2026). Browsers decide differently. Chrome grants it silently by heuristics and otherwise silently denies it, while Firefox prompts the user (LePage, n.d.). WebKit also grants by heuristics, such as whether the site is a Home Screen web app (Liu, 2023). An app can call estimate() to check whether space is left (van Kesteren, 2026).

Safari’s seven-day deletion

Safari deletes script-writable storage after seven days without a visit. Its tracking prevention “deletes all cookies created in JavaScript and all other script-writeable storage after 7 days of no user interaction with the website” (WebKit, n.d.c). The first-party domain of Home Screen web apps is exempt (WebKit, n.d.c).

A WebKit engineer later said HTML storage should not be deleted for a Home Screen app’s main domain. Browsers had agreed on a roughly 400-day cap for cookies, the engineer added, and it might one day extend to HTML storage. None of these caps had shipped by March 2022 (WebKit Bugzilla, 2022).

Does data get lost in practice? Weak evidence: few or small studies support this

How often stored data is lost in practice rests on thin evidence. Chrome guidance, reporting Chrome team research, says data is very rarely cleared automatically, and that users clearing it by hand is far more common (LePage, n.d.). Before the Safari cap shipped, a developer filed a bug predicting it would cause loss of user-generated IndexedDB data. The report was closed as a duplicate, and an engineer noted the Home Screen carve-out (WebKit Bugzilla, 2020).

Speed benefits Weak evidence: few or small studies support this

The measured speed benefit of service workers comes from one site. On the Google I/O 2016 web app, median first paint on desktop was 583 ms with a controlling service worker and 912 ms without one (Walton, n.d.). The author cautions that comparing the service-worker cache with the HTTP cache “is not entirely fair” because the app was optimised for service workers (Walton, n.d.).

Speed matters in laboratory studies of interaction. An extra 500 ms of delay reduced user activity and dataset coverage in an experiment with interactive visualisations (Liu & Heer, 2014). Another set of controlled experiments found that task type and complexity can modulate or remove the effect of latency (Battle et al., 2019).

Connectivity bugs in apps

Studies of apps that sync data show that handling a lost connection is hard. Both studies below examine native Android apps, not web apps.

In a failure-injection study of popular apps, including ones syncing through Dropbox, Parse and Kinvey, apps showed data loss, corruption and inconsistent behaviour (Go et al., 2015). No app recovered correctly from a crash during an object update, and some apps never told the user that sync had failed, leaving data perpetually pending (Go et al., 2015).

A manual study of 971 scenarios in 50 open-source apps found 304 eventual-connectivity issues, about six per app (Escobar-Velásquez et al., 2021). Most were messages that gave wrong information about connectivity, or misuse of external libraries that check it (Escobar-Velásquez et al., 2021).

History

Earlier attempts at offline web apps were retired in favour of what is now standard. Google Gears, released on 31 May 2007, included a SQLite database module, a LocalServer module that cached and served application resources, and a worker pool (Wikipedia contributors, 2026g). Google said it would keep supporting Gears but not invest in new features (Fiveash, 2010), and removed it from Chrome on 7 June 2011 (Wikipedia contributors, 2026g).

The HTML5 Application Cache followed, and Chrome began removing it in version 85 in August 2020. The Chrome team recommended migrating to service workers (Posnick, 2020).

A different line survives. PouchDB in the browser syncs with a CouchDB server by push and pull. When edits conflict, CouchDB picks an arbitrary winner that every node agrees on, and losing revisions stay in the revision tree (PouchDB contributors, n.d.). For how conflicting edits are merged, see Merging concurrent edits.

Further reading

Known gaps

What this article cannot tell you yet.

  1. No measurement of how often browsers evict stored data, or how often persist() is granted, was found; reports of data loss are anecdotal.
  2. Chrome’s own quota documentation was not read; Chrome figures come from MDN.
  3. Only part of the Service Workers specification text was read.
  4. The dates for Google Gears come from a news report and Wikipedia, not from Google.
  5. No peer-reviewed study of user-facing speed or availability gains from offline web apps was found; the Google I/O data are a single site.
  6. The connectivity-bug studies cover native Android apps; no equivalent study of web apps was found.

References

Solid source
Rated highly trustworthy by the research, and every passage taken from it was found in it.
Weak source
Rated low, or a passage taken from it was not found in it.
Medium trust
Rated medium by the research.
Not checked
Rated high, but its passages could not all be checked against it.
Show all 23 references