← Back to the workshop
Behind the scenes

pwa-kit

A small update helper with an offline fallback for previously visited resources.

pwa-kit

About The Project

A small service-worker update helper for web apps, with a visible update notice and a guard for unfinished work.

Copy sw.js, sw-update.js and pwa-update.js into an app's web root and wire them up. There is no frontend build step or package dependency. The ZIP also has an example and optional server integration files.

A new service worker activates immediately. Visible pages can postpone reloading while work is unfinished; unresponsive clients reload after a short grace period. Adapt the reference cache policy before using it for private content.

Gallery

Features

  • ⚡ Immediate Activation: New workers install and take over without stale workers lingering for days across open browser tabs.
  • 🛡️ Unsaved Work Guard (isBusy): Responsive, visible pages can defer reloads while edits are unfinished; apps should save important drafts separately.
  • 🌐 Network-First Freshness: Online requests always win to ensure deployed changes take effect on the very next reload, falling back to cache when offline.
  • 🔔 Clean Session Storage Notifications: Avoids polluting URL query strings with update flags, informing users cleanly through in-app toasts.
  • 🚨 Built-in Cache Escape Hatch: Includes an emergency unregister and cache-bust mechanism for wedged clients.