AGENT SKILL

pwa-architect

Architect-level progressive web app guidance — service-worker caching strategies and versioning, offline and stale-while-revalidate behaviour, the update flow users actually see, installability, and the security and debugging traps of a cache you control. Use when a site needs offline support or app-like install.

License 许可
MIT
最近更新
2026-11-13
Stars
★ 0
Forks
0

01 前言 Front Matter

name
pwa-architect
license
MIT
metadata
{ "crusor-path": "website-architect/frontend-development-architect/pwa-architect", "crusor-domain": "website-architect", "crusor-origin": "original", "crusor-sources": "developer.mozilla.org/Service_Worker_API; web.dev/learn/pwa; web.dev/service-worker-caching-and-http-caching", "crusor-triggers": "pwa, service worker, offline, cache storage, workbox, install prompt, web app manifest, stale-while-revalidate", "crusor-verified-on": "2026-10-30" }
description
Architect-level progressive web app guidance — service-worker caching strategies and versioning, offline and stale-while-revalidate behaviour, the update flow users actually see, installability, and the security and debugging traps of a cache you control. Use when a site needs offline support or app-like install.
compatibility
Service Workers, Cache Storage, Workbox or hand-rolled; any framework

03 SKILL.md 正文

PWA Architect

A service worker is a programmable proxy you now own. Every caching decision becomes a correctness bug when you get it wrong — usually "users see yesterday's app".

When to use

  • Offline or flaky-network support, app-like installation, background sync.
  • Debugging "the site is stale until a hard refresh".
  • Adding push notifications.

When NOT to use

  • A marketing site with no offline value — a service worker only adds a stale cache failure mode.
  • Auth-heavy apps where caching HTML would leak another user's data.

Decision 1 — Caching strategy per resource

Resource Strategy
versioned static assets (hash) cache-first, immutable
app shell / HTML network-first with short cache, or stale-while-revalidate
API GET network-first; cache only explicitly safe endpoints
API mutations never cached; queue with background sync where supported
fonts/images stale-while-revalidate with size cap
  • Never cache authenticated HTML or API responses in a shared cache without user scoping.
  • Every cached response has an expiry policy; unbounded caches are leaks.

Decision 2 — Versioning and updates

  • Cache names carry a build version; activation deletes old caches.
  • The update is a UX flow: detect a new worker → show "Update available" → activate on demand or on next navigation → never silently strand a running session.
  • skipWaiting + clientsClaim only with an explicit reload prompt; otherwise mixed versions produce impossible bugs.
  • Kill switch: a worker that can be removed remotely (self.registration.unregister()) when a bad release ships.

Decision 3 — Offline reality

  • Offline is a designed state: an offline page, queued writes, and clear indicators of what is pending.
  • Reads: last-known data with a timestamp, not a blank screen.
  • Writes: outbox with retry, conflict handling on reconnect.
  • Navigation fallback serves the app shell, not a browser error.

Decision 4 — Installability and manifest

  • Manifest: name, short_name, icons (192/512 + maskable), start_url, display, theme/background colours.
  • Install prompt is earned (after real engagement) and never on first paint.
  • iOS support is partial: test add-to-home-screen behaviour explicitly.

Decision 5 — Security and debugging

  • Service workers require HTTPS (localhost excepted); scope is the directory they live in.
  • Never inject HTML into a cached response without sanitising.
  • DevTools: "Bypass for network" and "Update on reload" during development; clear storage when switching branches.
  • Verify what is actually served: curl shows the network, DevTools shows what the user gets.

Failure modes at scale

  • Users stuck on an old build for days.
  • Cached API responses leaking between users after logout.
  • Caching the HTML of a route that changes per user.
  • A broken worker shipped with no kill switch — support cannot reproduce.
  • Storage quota exceeded silently, offline breaks.

Verification receipts

  1. Strategy table documented per route/asset type.
  2. Update test: ship a new build, confirm the prompt and the clean reload.
  3. Offline test: cold load with no network on the primary journey.
  4. Logout test: no previous user's data served from cache.
  5. Cache inventory: names, entries, size, expiry.

04 同仓库更多 Skills

SriAkhilSJ
SriAkhilSJ/PulseAIRepo

interaction-patterns-architect

Architect-level interaction design in code — choosing established patterns over invented ones, feedback and latency behaviour, destructive-action safeguards, navigation and overlay conventions, and the state model behind every interactive surface. Use when a screen has to behave, not just look.

★ 0
SriAkhilSJ
SriAkhilSJ/PulseAIRepo

design-system-ops-architect

Architect-level operation of a design system in code — token pipelines and versioning, component API and variant policy, the catalogue as the contract, adoption metrics, and the governance that stops a system from forking into three. Use when a component library must survive several teams.

★ 0
SriAkhilSJ
SriAkhilSJ/PulseAIRepo

design-handoff-architect

Architect-level design handoff — what must be specified before implementation starts, tokens over raw values, responsive and content-limit contracts, state matrices, and the review loop that catches drift between design and code. Use when a design is about to become code.

★ 0
SriAkhilSJ
SriAkhilSJ/PulseAIRepo

content-microcopy-architect

Architect-level UI content — where strings live, voice and terminology consistency, error and empty-state copy as part of the interface, translation-ready authoring, and the content model a product needs before it multiplies screens. Use when the words in the interface matter as much as the pixels.

★ 0
SriAkhilSJ
SriAkhilSJ/PulseAIRepo

ui-ux-implementation-architect

Architect-level direction for turning a design into working UI — the handoff contract, component ownership versus screen-level layout, interaction and state conventions, design QA gates, and the review habits that keep an implementation faithful without frozen pixels. Use before any specific UI implementation skill.

★ 0
SriAkhilSJ
SriAkhilSJ/PulseAIRepo

test-strategy-architect

Architect-level test strategy — allocating assertions across unit, integration, contract and end-to-end layers, designing for testability through dependency boundaries, fixture and data strategy, and the flake and coverage policies that keep a suite trustworthy. Use when defining how a codebase is tested.

★ 0