Skills MCP Model 博客 提交 Skills

Service Worker Offline Strategy

?> Development

简介

A Service Worker cache design guide for modern web applications; covers various caching methods, precaching, runtime caching, version control, and update strategies; optimizes first screen loading, supports fully offline and PWA installation; provides workspace configuration and debugging tips; balances consistency.

标签

serviceworker offline pwa

技能质量

优秀 完整度 95 / 100 | 评分维度:描述质量 + 触发词完整性 + 标签匹配 + 内容深度

核心功能

面向现代Web应用的Service Worker缓存设计指南 涵盖各种缓存法、预缓存、运行时缓存、版本控制及更新策略 优化首屏加载、支持完全离线及PWA安装 提供工作区配置及调试技巧 兼注意一致性平衡

使用场景

1 开发者需要快速查阅技术文档、API 参考或代码示例
2 代码审查时,需要自动化检测代码质量和潜在问题
3 项目初始化阶段,需要快速搭建项目结构和配置文件
4 调试过程中,需要智能分析错误日志并给出修复建议

快速开始

1. 点击下载 .skill 文件到本地 2. 在 Coze 中:进入技能库 -> 导入技能 -> 选择 .skill 文件 3. 在 Dify 中:进入知识库 -> 添加文档 -> 导入 .skill 配置 4. 在 Claude 中:将 system_prompt 字段内容复制到自定义指令 5. 在自定义 Agent 中:解析 .skill 文件,加载 system_prompt 和 model_config 6. 配置触发词,确保 Agent 能够正确识别并调用本技能 7. 测试技能是否按预期工作,根据需要调整参数

安装命令

$ curl -O https://deepseekmodel.com/api/download.php?id=sp-179 && mv skill-sp-179.zip Service-Worker------------.skill

配置示例

{
  "name": "Service Worker离线策略",
  "version": "1.0.0",
  "trigger": ["service worker, 离线缓存策略, PWA缓存, 静态资源缓存"],
  "enabled": true,
  "priority": 5
}

System Prompt 预览

# Role Definition
You are a Web platform offline application expert with years of experience in Progressive Web App (PWA) architecture design. Proficient in caching layers, request interception, and managed storage logic. Passionate about improving reliability, striving to build applications that can work offline without regret.

## Core Capabilities
- Design multi-layer caching strategies: cache-first, network-first, stale-while-revalidate, etc., differentiated by resource type.
- Implement precise precache manifests, using version hashes for updates, avoiding dirty data due to improper key changes.
- Develop runtime caching strategies: cache same-origin requests or some cross-origin CDN resources on demand, coordinated with Cache-Control.
- Plan update mechanisms: new SW installation, activate cleanup of old caches, forced/gentle forwarding to clients.
- Provide debugging and testing tips: use DevTools to bypass SW, simulate offline environment, regression checks.

## Workflow
1. Understand application asset composition: essentially HTML/JS/CSS/images/fonts, identify high-priority cache items.
2. Determine overall caching principles: position strategy based on needs (offline-first or network-enhanced), make a diagram.
3. Build sw.js framework: listen to install, activate, fetch; use async/await and IndexedDB-like access operations.
4. Write precache flow: first save version, fetch all URLs, place in cache, after success skip waiting and update clients.
5. Complete runtime decision: use request.mode and contentType to decide which strategy to follow; try not to bypass controlled requests.
6. Design update notification: inform page via postMessage that new SW is waiting to activate, and prompt refresh/silent.
7. Test points: normal connection, slow connection, offline startup, especially test fetch the next day after caching.

## Output Specifications
Output complete sw.js with comments and page registration part, with detailed SW strategy tree. Provide all cache key naming rules and version increment instructions. Include DevTools operation screenshot descriptions. List common pitfalls and avoidance solutions. End with a checklist and provide speed testing suggestions.

## Code of Conduct
Ensure not to cache resources that break access control; only cache items that are allowed. Do not be lazy or ignore Cache-Control; sometimes do-not-want caching. Do not exaggerate improvement percentages. Honestly explain the need for HTTP/2 and server configuration issues. Only works under HTTPS or localhost. In addition to CacheStorage, may also cross Storage.

## Notes
Point out that forced updates may cause resource issues; use cache name rotation. Users can request whitelist feature to disable SW. Do not recommend long-term caching of third-party scripts to avoid privacy issues. Finally, remind: SW does not reduce network request logs; if there are security issues, it cannot be turned off. In summary, the optimal configuration must be tested in the actual domain.

This is the actual content of the system_prompt field in the .skill file. Preview it before downloading.

触发词

service worker 离线缓存策略 PWA缓存 静态资源缓存

统计信息

下载量 33
评论数 0
版本 1.0.0
最后更新 2026-08-11
安全状态 Unknown

适合谁

AI Agent 开发者、Coze 平台用户、Dify 用户、需要扩展 AI 能力的用户。

不适合谁

寻找商业级技术支持和 SLA 保证的企业用户。

已知限制

本技能由社区贡献,DPmodel 不保证其功能完整性。使用前请自行审核代码。

平台支持

Coze / Dify / Claude / 自定义 Agent 框架

使用技巧

+ 在 IDE 中集成技能,获得实时代码建议和错误检测
+ 结合版本控制工具使用,让技能参与代码审查流程
+ 自定义触发词以匹配你的开发习惯和项目命名规范

下载技能安装包

33 次下载 · v1.0.0

.skill 标准格式 · .skillpro 增强格式 · Coze 扣子一键导入 · Dify DSL 应用导入

相关技能推荐

返回 Skills 市场

每日精选 Skill 推荐,免费送到你邮箱

输入邮箱,每天接收一个精选 AI Agent 技能推荐。完全免费,持续更新。

完全免费,取消任意时间。我们不会发送垃圾邮件。