Service workersBaseline · Widely available
The service worker of a website is a script that runs in its own thread and which acts as local proxy that intercepts network requests from the website. Use a service worker to implement advanced caching strategies, offline support, background tasks, or push notification support on your website.
Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Apr 30, 2018. Widely available since Oct 30, 2020.
Browser support
DesktopChrome
1–44Not supported
45+Supportedsince Sep 1, 2015
Current: 155Edge
12–16Not supported
17+Supportedsince Apr 30, 2018
Current: 154Firefox
1–43Not supported
44+Supportedsince Jan 26, 2016
Current: 157Safari
1–11Not supported
11.1+Supportedsince Apr 12, 2018
Current: 27MobileChrome Android
18–44Not supported
45+Supportedsince Sep 1, 2015
Current: 155Firefox Android
4–43Not supported
44+Supportedsince Jan 26, 2016
Current: 157Safari iOS
1–11Not supported
11.3+Supportedsince Mar 29, 2018
Current: 27How to use
This feature is Baseline widely available — use it freely, no fallback needed.
Example
JS
// main.js
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("/sw.js");
}
// sw.js — cache-first for static assets
self.addEventListener("fetch", (event) => {
event.respondWith(
caches.match(event.request).then((hit) => hit ?? fetch(event.request)),
);
});Feature detection
JS · check before using
if ("ServiceWorker" in globalThis) {
// ServiceWorker is available
} else {
// load a polyfill or use a fallback
}Specification
Usage share
Sub-features
Support for each part of the feature (100). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| Cache | 40 | 16 | 41 | 11.1 | 40 | 41 | 11.3 |
| Cache.add | 44 | 16 | 41 | 11.1 | 44 | 41 | 11.3 |
| Cache.addAll | 46 | 16 | 41 | 11.1 | 46 | 41 | 11.3 |
| Cache.delete | 43 | 16 | 41 | 11.1 | 43 | 41 | 11.3 |
| Cache.keys | 43 | 16 | 41 | 11.1 | 43 | 41 | 11.3 |
| Cache.match | 43 | 16 | 41 | 11.1 | 43 | 41 | 11.3 |
| Cache.matchAll | 47 | 16 | 41 | 11.1 | 47 | 41 | 11.3 |
| Cache.put | 43 | 16 | 41 | 11.1 | 43 | 41 | 11.3 |
| Cache.worker_support | 40 | 16 | 44 | 11.1 | 40 | 44 | 11.3 |
| CacheStorage | 43 | 16 | 41 | 11.1 | 43 | 41 | 11.3 |
| CacheStorage.delete | 43 | 16 | 41 | 11.1 | 43 | 41 | 11.3 |
| CacheStorage.has | 43 | 16 | 41 | 11.1 | 43 | 41 | 11.3 |
| CacheStorage.keys | 43 | 16 | 41 | 11.1 | 43 | 41 | 11.3 |
| CacheStorage.match | 54 | 16 | 41 | 11.1 | 54 | 41 | 11.3 |
| CacheStorage.open | 43 | 16 | 41 | 11.1 | 43 | 41 | 11.3 |
| CacheStorage.secure_context_required | 65 | 79 | 44 | 11.1 | 65 | 44 | 11.3 |
| CacheStorage.worker_support | 43 | 16 | 44 | 11.1 | 43 | 44 | 11.3 |
| Client | 40 | 17 | 44 | 11.1 | 40 | 44 | 11.3 |
| Client.frameType | 43 | 17 | 44 | 11.1 | 43 | 44 | 11.3 |
| Client.id | 40 | 17 | 44 | 11.1 | 40 | 44 | 11.3 |