browser-caching
它能做什么
这项技能检查网站如何要求浏览器存储其文件,以便在之后的访问中使用。适合希望回访速度更快的开发者。
适用场景
- ✓当回访的访客每次仍然重新下载相同的文件时。
- ✓当你为图片、脚本或样式表设置缓存标头时。
- ✓当页面已更新,但访客仍然看到旧内容时。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/browser-caching/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请设置缓存,让回访的人能够快速加载我网站的图片和脚本。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会为带哈希值的资源文件设置较长的缓存时间,为 HTML 页面设置较短的缓存并配合重新验证,并使用 ETag,使浏览器能检查文件是否已更改。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Enable browser caching
Proper caching eliminates redundant downloads on repeat visits—returning users see near-instant page loads when assets are served from browser cache.
Quick Reference
- Use immutable caching for hashed assets (1 year max-age)
- Use short cache + revalidation for HTML pages
- ETags enable efficient cache validation
- stale-while-revalidate improves perceived performance
Check
Verify that proper cache headers are set for static resources to enable browser caching.
Fix
Configure appropriate Cache-Control and ETag headers for different resource types.
Explain
Explain how browser caching reduces server requests and improves repeat visit performance.
Code Review
Review the routes, assets, and loading behavior that affect Enable browser caching. Flag exact files, requests, or rendering steps that add unnecessary network, CPU, or layout cost, and describe the measurement method used to confirm the issue.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/performance/browser-caching
常见问题
带哈希值的文件应设置多长的缓存时间?
这项技能建议对带哈希值的资源使用 immutable 缓存,最长为一年。
HTML 页面呢?
这项技能建议使用较短的缓存,并配合重新验证,使内容保持最新。
什么是 ETag?
它是一个小标识符,浏览器会将其发回,以便服务器确认文件是否已更改。
详情
作者的原始描述
Use when auditing slow page loads, heavy assets, or rendering delays related to Enable browser caching. Verify the actual bottleneck in DevTools, Lighthouse, or field data before recommending changes.
热度
- GitHub 星标
- 75k
- 排名
- #2762
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。