Skip to main content

Confirm

Are you sure?

Mobile · Checked once per domain

PWA service workerWhat it checks and how to fix it

What it checks

Looks for a service worker on the site: registration code in the homepage HTML (navigator.serviceWorker.register, Workbox, a sw.js reference), a file at /sw.js, /service-worker.js or /serviceworker.js, or a Service-Worker-Allowed header. Any of these passes; none is a warning.

Why it matters

A service worker lets a site keep working offline or on a flaky connection, load repeat visits from cache, and receive push notifications. It is required for a site to be installable as a progressive web app. For content sites it is optional, which is why its absence is only a warning.

How to fix it

Register a service worker from the page:

<script>
  if ("serviceWorker" in navigator) {
    navigator.serviceWorker.register("/service-worker.js");
  }
</script>

A minimal worker that caches the offline essentials:

// /service-worker.js
const CACHE = "v1";
self.addEventListener("install", (event) => {
  event.waitUntil(caches.open(CACHE).then((cache) => cache.addAll(["/", "/offline.html"])));
});
self.addEventListener("fetch", (event) => {
  if (event.request.mode !== "navigate") return;
  event.respondWith(fetch(event.request).catch(() => caches.match("/offline.html")));
});

Serve the worker from the site root (its scope is the folder it lives in) with Cache-Control: no-cache so updates are picked up. Rails 7.2+ ships one at app/views/pwa/service-worker.js; uncomment its route in config/routes.rb. For anything more than this, use Workbox.

Monitor this automatically

Full Stack Audit runs this check and 126 others on your site on a schedule, and emails you when one that passed starts failing.

More Mobile checks