Download
- What happens
- The browser downloads the service worker file when a user first visits a page it controls
A service worker is a script that sits between a web app, the browser and the network. See the lifecycle, HTTPS rule, registration code and the SEO caveat.
A service worker is a JavaScript worker that acts as a proxy between a web app, the browser and the network. MDN says it can enable offline experiences and intercept network requests. It needs HTTPS (localhost is allowed), has no DOM access, and moves through download, install and activate.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
MDN describes service workers as acting "as proxy servers that sit between web applications, the browser, and the network (when available)." They are intended, among other things, "to enable the creation of effective offline experiences, intercept network requests, and take appropriate action based on whether the network is available, and update assets residing on the server."
A service worker is a type of web worker. It runs in a worker context: it has no DOM access, runs on a different thread from your page's JavaScript, and is designed to be fully asynchronous.
The scope option is optional and sets which part of your content the worker controls. With "/" it controls all content under the origin. By default, MDN says, the scope is the directory where the worker file is located. To ship an update, give the new version its own cache name in the install event and delete old caches in activate, as MDN's guide shows.
if ("serviceWorker" in navigator) {
const registration = await navigator.serviceWorker.register("/sw.js", {
scope: "/",
});
}MDN says a service worker is a type of web worker, so the two share the no-DOM, separate-thread model. A service worker also has no access to synchronous XHR or Web Storage.
4 questions people ask next, answered from the sources on this page.
A script your browser runs in a worker context that sits between your web app and the network, so it can cache files and handle requests, including when the network is unavailable.
Yes. A service worker is a standalone browser API. Progressive web apps use it, but you can register one on any HTTPS site.
No. They run in a worker context on a different thread and have no DOM access.
Yes, they are only available in secure contexts. Browsers also allow localhost for development.
The free audit reads robots.txt, sitemaps, status codes, canonicals, redirects and structured data.