Produce vanilla service-worker.js code using the Cache API: precache URLs on install, pick a fetch strategy (network-first, cache-first,
stale-while-revalidate, and more), optionally wire an offline fallback page, and copy a matching registration snippet. Generation stays in your browser — nothing is
uploaded.
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.
A service worker is a script that the browser runs separately from your page. It can intercept network requests, cache responses, and enable offline and
faster repeat visits for progressive web apps (PWAs). This generator outputs plain JavaScript using the caches and fetch APIs — no bundler
required.
On install, the generated worker calls cache.addAll(PRECACHE_URLS). If any URL fails (404, CORS, etc.), the install event can fail — test in DevTools →
Application → Service Workers. Change Cache name when you ship breaking updates so “delete old caches” can remove previous versions.
Google’s Workbox library adds routing, plugins, and build integration for large apps. DroidXP’s output is intentionally small and readable for learning and quick prototypes — swap to Workbox when you need precaching pipelines, runtime caching rules, or background sync.
Service workers require a secure context (HTTPS or localhost). The registration snippet uses scope: '/' — tighten or widen it in your project to match where
the SW file is served from.
No. The tool only builds text in your browser. You host the file on your own origin and register it from your pages.
addAll fail during install?One bad URL fails the whole batch. Verify each precache path returns 200, watch CORS for cross-origin assets, and use DevTools to see which request failed.
Browsers keep the old worker until tabs close or a new worker takes over. skipWaiting() and clients.claim() help, but you may still need to reload or implement a
“refresh to update” UX.
Responses must be CORS-enabled for cache.put to store useful copies; opaque responses are hard to reuse. Prefer same-origin assets or APIs with proper CORS headers.
The generated fetch handler ignores non-GET requests so forms and APIs are not accidentally cached — extend the script yourself if you need custom POST handling.
It trades a fast paint against possibly stale content. For APIs that must be fresh, prefer network first or skip runtime caching for those paths (add routing logic in your own code).
Service workers work without a manifest. A manifest is separate — it is required for “install to home screen” branding, not for basic SW registration.
Treat the output as a starting point. Add error handling, routing for APIs, size limits, and monitoring. For large PWAs, evaluate Workbox or a framework-specific PWA plugin.