Static sites make excellent PWAs: every page is a file, so caching is simple and safe.
Astro
npx astro add @vite-pwa/astro
// astro.config.mjs
import { defineConfig } from 'astro/config';
import AstroPWA from '@vite-pwa/astro';
export default defineConfig({
integrations: [AstroPWA({
registerType: 'autoUpdate',
manifest: { name: 'My Site', short_name: 'Site', theme_color: '#5A0FC8', icons: [/* ... */] },
workbox: { navigateFallback: '/404', globPatterns: ['**/*.{css,js,html,svg,png,ico,txt}'] },
})],
});
Eleventy, Hugo, Jekyll or any static output
Run the Workbox CLI after your build to generate a worker with a precache list of the output folder:
npx workbox-cli wizard # once: answers saved to workbox-config.js
npx workbox-cli generateSW workbox-config.js
For large sites, do not precache every page; precache the shell and use a network-first runtime rule for HTML.
Small sites
For a blog or brochure site, a 40-line hand-written worker is enough. Generate one with our service worker generator, add a manifest and icons, and you are done.