Service Worker offline caching
Installs a script that caches pages and answers requests when offline.
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
| Browser | Status | First version | Released | Note |
|---|---|---|---|---|
| Chrome | Supported | 40 | 2015-01-21 | None |
| Edge | Supported | 17 | 2018-04-30 | None |
| Firefox | Supported | 44 | 2016-01-26 | None |
| Safari | Supported | 11.1 | 2018-04-12 | None |
| Safari on iPhone | Supported | 11.3 | 2018-03-29 | All iOS browsers use WebKit |
| Chrome on Android | Supported | 40 | 2015-01-21 | None |
| Samsung Internet | Supported | 4.0 | 2016-03-11 | None |
How a site asks for it
| API | navigator.serviceWorker.register(); caches.open(); fetch event |
| Browser compat keys | api.ServiceWorkerapi.CacheStorageapi.ServiceWorkerRegistration |
| How access is granted | none |
| What the user sees | None (no browser prompt) |
| Needs a secure context (HTTPS) | Yes |
| Needs a user gesture | No |
| Activation | none |
| How long it lasts | Persists until unregistered or storage cleared; Safari ITP may delete after 7 days of no interaction |
| How to take it back | Nothing to revoke (no permission is stored) |
| Inside an iframe | Same origin only; scope limited to script path unless Service-Worker-Allowed header is set |
Typical flow
- Page registers service worker (HTTPS)
- Browser installs, activates
- 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
| Type | Example | Apps |
|---|---|---|
| media | A music or podcast web app plays saved episodes with no signal. | None named |
| travel | A flight status or map site loads from its saved copy in an airport with weak wifi. | Google Maps Go |
| social | A lite social site opens in a flash on a slow phone. | Twitter Lite, Pinterest |
| games | A browser game stores its art and levels so it starts fast and plays offline. | None named |
| shopping | A store saves its catalog shell so browsing is fast on a bad connection. | Starbucks, AliExpress |
| security | A 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
- Google: Service workers. web.dev teaches service workers as the base of installable, offline capable web apps.
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
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 2 of 5 | How revealing the data is |
| Utility | 5 of 5 | How useful it is to honest apps |
| Friction | 0 of 5 | How much the user has to do |
| Fingerprint bits | Not rated | Rough 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.