360 Secure SkillHub
360 安全技能中心

Pwa Implementation

用于为 Web 应用添加 PWA 能力:配置 manifest 与图标(含 Android maskable、iOS apple touch icon),注册 Service Worker 并设计可见更新提示,用 Workbox 管理预缓存与运行时缓存,提供离线兜底页与安装引导。适合移动端/桌面端安装、弱网离线、高频回访;纯内部后台或强实时流媒体不必强上。缓存需区分页面、静态资源、API 与登录支付等敏感请求。

bovinphang
bovinphang
热度 55.43
最近更新 2026-09-26 23:13:49
分类:开发依赖:代码执行 / 读写文件应用场景:代码生成 / 工作流 / 模板

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add fec-pwa-implementation
Metadata
name
fec-pwa-implementation
description
Use when adding or reviewing Progressive Web App capabilities such as installability, manifest metadata, Service Worker registration, Workbox caching, offline fallback, app update prompts, maskable icons, or iOS PWA compatibility. Do not use for general API caching or non-installable performance tuning; Chinese triggers include PWA, offline, Service Worker.

PWA implementation

Purpose

Make web applications installable, offline and controllable to update.

Procedure

  1. Confirm whether PWA is worth doing: priority is given to mobile/desktop installations, weak network offline, and repeated access scenarios; do not force PWA when it is purely internal backend, has strong real-time streaming media, or only requires ordinary caching.
  2. First complete the manifest, icon, theme color and HTML reference; the icon covers at least 192/512, Android needs to be maskable, and iOS needs apple touch icon.
  3. Register the Service Worker and design an update prompt; do not forcefully refresh the user page after silently skipWaiting().
  4. Use Workbox or framework plug-in to manage precache/runtime cache; sensitive requests such as login, payment, and permission changes must go through the network.
  5. Provide offline fallback page and installation prompt UI, and verify initial loading, offline access, update activation, uninstallation and reinstallation.

Detailed reference

Constraints

  • Service Worker only works under HTTPS (except localhost).
  • The caching strategy must distinguish between pages, static resources, APIs and sensitive operations; do not cache login, payment, and permission interfaces.
  • Service Worker updates have a lifecycle delay; user-visible refresh prompts take precedence over forced refreshes.
  • iOS PWA capabilities are weaker than Android, and installation, push and life cycle must be verified separately.
  • The cache has quotas and eviction mechanisms, and max entries / max age must be set.

Expected Output

Produce installable web apps, offline fallbacks, visible update prompts, and explicit caching policies. Validate Lighthouse PWA, DevTools Application panel, offline mode, update release and mobile installation process.