> PWA Service Worker
Build offline-capable web apps with service workers and caching strategies.
fetch
$
curl "https://skillshub.wtf/skillshub-team/catalog-batch5/pwa-service-worker?format=md"SKILL.md•PWA Service Worker
PWA Service Worker
Registration
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js', { scope: '/' });
}
sw.js — Cache-First + Network-First
const CACHE = 'v1';
const STATIC = ['/', '/index.html', '/styles.css', '/app.js'];
self.addEventListener('install', (e) => {
e.waitUntil(caches.open(CACHE).then(c => c.addAll(STATIC)));
self.skipWaiting();
});
self.addEventListener('activate', (e) => {
e.waitUntil(caches.keys().then(keys =>
Promise.all(keys.filter(k => k !== CACHE).map(k => caches.delete(k)))));
self.clients.claim();
});
self.addEventListener('fetch', (e) => {
if (e.request.url.includes('/api/')) {
e.respondWith(fetch(e.request).catch(() => caches.match(e.request)));
} else {
e.respondWith(caches.match(e.request).then(c => c || fetch(e.request)));
}
});
Strategies
- Cache-first: Static assets
- Network-first: API calls
- Stale-while-revalidate: Semi-dynamic content
> related_skills --same-repo
> Nix Dev Shells with direnv
Auto-activate reproducible dev environments with Nix flakes and direnv.
> Dagger with GitHub Actions
Run Dagger CI/CD pipelines in GitHub Actions for portable, testable builds.
> Bun + Hono API
Build fast APIs with Bun runtime and Hono framework.
> Deno Fresh Framework
Build full-stack web apps with Fresh on Deno. Islands, routes, and zero runtime overhead.
┌ stats
installs/wk0
░░░░░░░░░░first seenMar 18, 2026
└────────────