Developer

Readable service-worker.js. You still host and register it.

Vanilla Cache API: precache URLs on install, then network-first, cache-first, stale-while-revalidate, network-only, or cache-only. Optional offline fallback and a navigator.serviceWorker.register snippet. Not Workbox. One 404 in addAll fails the whole install.

Bump this when you change precache or breaking cache logic.

Must match where you deploy the generated file.

Passed to cache.addAll on install — every URL must respond successfully or install can fail.

Used for navigate requests when network/cache miss handling allows (strategy-dependent). Precache this page if you rely on it offline.

When to use this — and when not to

Use it for a small vanilla Cache API worker: precache a short URL list, pick a fetch strategy, optional offline HTML, plus a register() snippet.

Do not treat this as Workbox, a PWA audit, or an installability check. Pair it with a manifest.json if you want a home-screen icon — that is a separate file. Service workers need HTTPS or localhost.

What the generator actually emits

Strategies: network-first, cache-first, stale-while-revalidate, network-only, cache-only. Precache uses cache.addAllone 404 fails the whole install. Non-GET requests are left alone so forms are not cached. skipWaiting / clients.claim / prune-old-caches are checkboxes.

Worked example

Cache name shell-v2, network-first, precache / and /offline.html:

const CACHE_NAME = "shell-v2";
const PRECACHE_URLS = [
  "/",
  "/offline.html",
];

Host the JS at the path you typed in “Register path”. Then Application → Service Workers in Chrome. If install fails, one precache URL is wrong or CORS-blocked.

Mistakes people make

  • Leaving cache name unchanged after a breaking HTML change — old shell sticks.
  • Caching POST APIs (the generated fetch handler does not; do not add it blindly).
  • Registering from HTTP on a LAN IP that is not localhost.

Related

PWA manifest generator · SPA .htaccess fallback

Frequently asked questions

Does DroidXP host the worker?

No. Text only. You upload it to your origin.

Why did addAll fail?

Any missing precache URL fails install. Check each path returns 200.

Updates not showing?

Old workers wait for tabs to close unless skipWaiting + claim. Add a “reload” UX.

Need a manifest?

Not for the worker. Yes for install branding.