Skip to Content
Platform.Ontology

Service Worker offline caching

Installs a script that caches pages and answers requests when offline.

Works without askingThings a page can doBackgroundWeb browsersWhile you use itAfter you leave the site

In one line

Can save pages on your device so the site works offline

Installs a script that caches pages and answers requests when offline.

A site can keep running its own code between visits and serve content from a local cache. Safari deletes script-written storage after 7 days without interaction; Chrome keeps it until cleared.

What it can and can't do

What the user does: You open the site once. It installs by itself, with no pop up.

It can

  • Save pages, images and files on your device for later
  • Show saved pages when you have no signal
  • Answer or change requests the site makes, even when you are offline

It cannot

  • Work on a site that has not been opened over a secure connection (HTTPS)
  • Use unlimited storage; browsers set a limit and may clear it
  • Stay saved forever; Safari on iPhone can clear it after 7 days of no use
  • Reach other sites' saved files

How it differs between platforms: Safari on iPhone can clear saved data after about 7 days without a visit, unless the site is added to your Home Screen.

Browser support

BrowserStatusFirst versionReleasedNote
ChromeSupported402015-01-21None
EdgeSupported172018-04-30None
FirefoxSupported442016-01-26None
SafariSupported11.12018-04-12None
Safari on iPhoneSupported11.32018-03-29All iOS browsers use WebKit
Chrome on AndroidSupported402015-01-21None
Samsung InternetSupported4.02016-03-11None

How a site asks for it

APInavigator.serviceWorker.register(); caches.open(); fetch event
Browser compat keysapi.ServiceWorker
api.CacheStorage
api.ServiceWorkerRegistration
How access is grantednone
What the user seesNone (no browser prompt)
Needs a secure context (HTTPS)Yes
Needs a user gestureNo
Activationnone
How long it lastsPersists until unregistered or storage cleared; Safari ITP may delete after 7 days of no interaction
How to take it backNothing to revoke (no permission is stored)
Inside an iframeSame origin only; scope limited to script path unless Service-Worker-Allowed header is set

Typical flow

  1. Page registers service worker (HTTPS)
  2. Browser installs, activates
  3. fetch events return cached or network responses

Data you get

Shape: none

No individual data fields. The signal is the access itself.

Technical limits

  • HTTPS or localhost only
  • Idle service workers terminate after about 30 s; a single event can run up to about 5 minutes in Chrome
  • Browser checks for a new worker script at most every 24 h (byte compare) and on navigation
  • Safari (ITP) caps script-writable storage including service worker registrations and Cache API at 7 days of no user interaction (not for Home Screen web apps)
  • Cache API quota shared with origin quota (Chrome up to 60% of disk per origin; Firefox about 10% of disk, up to 10 GiB per group)
  • Cannot run while the browser is closed except via push or background sync (permission and platform needed)

The story

What it is

A site can install a helper that stores pages and works when you are offline.

For you

A site opens instantly the second time and may even work on a plane. You never approve it, and it lives on after you close the tab.

For makers

Makers get offline use, quick starts and push messages, which lifts return visits. It also lets them update an app silently in the background.

Where you see it

TypeExampleApps
mediaA music or podcast web app plays saved episodes with no signal.None named
travelA flight status or map site loads from its saved copy in an airport with weak wifi.Google Maps Go
socialA lite social site opens in a flash on a slow phone.Twitter Lite, Pinterest
gamesA browser game stores its art and levels so it starts fast and plays offline.None named
shoppingA store saves its catalog shell so browsing is fast on a bad connection.Starbucks, AliExpress
securityA malicious site may keep a helper installed to serve ads or show alerts later, which is why you can clear site data.None named

Risks

  • Stays after closing
  • Stale or stuck copies

What the platform says

Good uses and abuse

Legitimate uses

  • Offline apps
  • Fast repeat loads
  • Push and sync host

Known abuse

  • Persistent foothold for tracking and malware
  • Hidden background fetches

Scores

ScoreValueMeaning
Sensitivity2 of 5How revealing the data is
Utility5 of 5How useful it is to honest apps
Friction0 of 5How much the user has to do
Fingerprint bitsNot ratedRough identifying entropy, when known

History

  • 2015-04, Chrome 40: Service Workers ship
  • 2018-03, Safari 11.1: Service Workers ship in Safari
  • 2020-03, Safari 13.1: ITP caps script-writable storage including SW at 7 days

Sources

How well checked: Based on official documentation.

On this page