跳到正文
Skillpedia
网站与界面(前端)75k · #2957

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。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/offline-fallback/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#2957
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能