offline-fallback
它能做什么
这个技能设置一个简单的离线页面,以及一个在页面无法加载时显示该页面的 Service Worker。它面向构建渐进式 Web 应用或在不稳定网络中使用的网站的开发者。
适用场景
- ✓你请智能体为网站或渐进式 Web 应用添加离线支持的时候。
- ✓访客在网络不稳定时看到浏览器默认的错误页面,而你希望有自己品牌的替代页面的时候。
- ✓你在设置 Service Worker,并希望它能妥善处理失败的页面请求的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/offline-fallback/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我为网站添加自定义离线页面,让网络不好的访客也能看到有用的内容吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会创建一个独立的离线页面,它不依赖外部资源即可加载。它会设置 Service Worker,在安装时缓存该页面,并在页面导航失败时显示它。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Provide an offline fallback page
The browser's default offline error screen ("No internet connection") is confusing and completely outside your brand. A custom offline page maintains the user experience, reinforces trust, and can surface cached content or useful actions — such as enabling users to continue reading a cached article or queuing a form submission for later.
Quick Reference
- Create a minimal /offline HTML page that works without any network requests
- Pre-cache the offline page during the service worker install event
- Intercept failed navigation requests and serve the offline page instead
- Include helpful guidance so users know what to do while offline
Check
Check whether the site shows a custom offline fallback page when the network is disconnected and a navigation request cannot be fulfilled.
Fix
Create a self-contained /offline page and configure the service worker to pre-cache it and serve it for failed navigation requests.
Explain
Explain how a service worker can intercept failed network requests and return a cached offline fallback page to the user.
Code Review
Review the service worker fetch handler and the offline page markup. Verify the offline page is pre-cached at install time, that it does not depend on external resources, and that the fallback is only served for navigation requests (not sub-resources).
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/performance/offline-fallback
常见问题
为什么离线页面必须能独立工作?
这个技能说,它不应依赖网络请求,因为用户离线时正是这些请求会失败。
离线页面对图片和脚本也适用吗?
不适用。这个技能说,备用页面只应用于页面导航请求,而不用于子资源。
它能显示缓存的内容吗?
可以。这个技能提到可以展示缓存内容,或提供有用的操作,例如把表单排队以便稍后提交。
详情
作者的原始描述
Use when adding PWA capabilities, implementing a service worker, or improving the experience for users on unreliable network connections.
热度
- GitHub 星标
- 75k
- 排名
- #2957
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。