PWA in Practice: Installable, Offline-Ready Tool Sites

技术架构(Updated May 27, 2026)

What Is a PWA?

A PWA (Progressive Web App) gives web apps an experience close to native apps:

Capability Traditional Web PWA
Install to home screen ✅ Add to Home Screen
Offline access ✅ Service Worker cache
Push notifications ✅ Push API
Full-screen ✅ standalone mode
Auto updates ✅ background SW updates

For high-frequency tool sites like ToolsKu, a PWA means users can open PDF merge, JSON formatters, and other favorites in one tap—like a native app.


Web App Manifest

manifest.json defines install metadata:

{
  "name": "ToolsKu - Online Tools Collection",
  "short_name": "ToolsKu",
  "start_url": "/en/",
  "display": "standalone",
  "background_color": "#ffffff",
  "theme_color": "#2563eb",
  "icons": [
    { "src": "/icons/icon-192.png", "sizes": "192x192", "type": "image/png" },
    { "src": "/icons/icon-512.png", "sizes": "512x512", "type": "image/png" }
  ]
}
Field Role
display: standalone Hides the browser address bar
start_url Page opened after install
theme_color Status/title bar color
icons Home screen icons (at least 192px and 512px)

Service Worker Caching Strategies

Cache first (static tool assets)

// Good for: JS/CSS/WASM/fonts that rarely change
self.addEventListener('fetch', (event) => {
  event.respondWith(
    caches.match(event.request).then(cached => {
      return cached || fetch(event.request).then(response => {
        const clone = response.clone();
        caches.open('static-v1').then(cache => cache.put(event.request, clone));
        return response;
      });
    })
  );
});

Network first (HTML pages)

// Good for: HTML that may update
event.respondWith(
  fetch(event.request).catch(() => caches.match(event.request))
);

ToolsKu cache tiers

Resource Strategy TTL
_next/static/** Cache First 1 year (hash filenames)
*.wasm Cache First 1 year
*.html Network First 1 hour
i18n JSON Stale While Revalidate 1 day

Offline Tool UX

UX design when the PWA is offline:

User opens ToolsKu offline
     ↓
Service Worker returns cached HTML/JS/CSS
     ↓
Tool page loads (SSG pre-rendered HTML)
     ↓
Client Component starts; tool logic runs locally
     ↓
File API / WASM processes files → fully offline

All core ToolsKu tools (PDF, images, JSON, crypto) use browser-local APIs and work offline by nature—the PWA only needs to cache static assets.


Install Prompt Best Practices

let deferredPrompt: BeforeInstallPromptEvent;

window.addEventListener('beforeinstallprompt', (e) => {
  e.preventDefault();
  deferredPrompt = e;
  showInstallBanner(); // custom install UI
});

installButton.addEventListener('click', async () => {
  deferredPrompt.prompt();
  const { outcome } = await deferredPrompt.userChoice;
  if (outcome === 'accepted') hideInstallBanner();
});

Tip: Don’t show the install prompt too early. After the user successfully uses 2–3 tools, conversion rates are higher.


Summary

PWAs are an effective way to improve retention on tool sites. Web App Manifest provides the install entry; Service Worker enables offline caching; and ToolsKu’s browser-local processing architecture makes offline tools feel the same as online.

Try these browser-local tools — no sign-up required →

#PWA#Service Worker#离线#Web App Manifest#安装