Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)75k · #3016

service-worker

Skill này làm gì

Skill này kiểm tra xem site có đăng ký service worker không và thêm lưu đệm cho tệp tĩnh cùng phương án dự phòng ngoại tuyến khi cần. Skill dành cho lập trình viên muốn các lần truy cập lặp lại nhanh hơn và hiệu năng di động tốt hơn.

Khi nào nên dùng

  • ✓Khi bạn yêu cầu agent thêm lưu đệm hoặc hỗ trợ ngoại tuyến cho website.
  • ✓Khi các lần truy cập lặp lại chậm và các tệp tĩnh bị tải lại mỗi lần.
  • ✓Khi bạn chuẩn bị progressive web app và cần một service worker hoạt động.

Liên kết skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/service-worker/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/service-worker/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Bạn có thể thêm service worker vào site của tôi để nó tải nhanh hơn ở các lần truy cập lặp lại và vẫn chạy được khi mạng yếu không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent đăng ký một service worker trong script chính, lưu đệm trước các tệp tĩnh quan trọng trong lúc cài đặt, và chọn cách lưu đệm cho từng loại tài nguyên. Agent cũng thêm bước activate để xóa các cache cũ khi site được cập nhật.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Register a service worker for caching and offline support

Service workers act as a programmable network proxy between the browser and the network. They eliminate repeated server round-trips for static assets, cut load times on repeat visits by 50–90 %, and allow the app to function at all on flaky or offline networks — which is critical for users on mobile or low-bandwidth connections.

Quick Reference

  • Register a service worker in your main JavaScript entry point
  • Use an install event to pre-cache critical static assets
  • Choose a caching strategy (cache-first, network-first, stale-while-revalidate) per resource type
  • Implement an activate event to clean up old caches on update

Check

Check whether a service worker is registered and whether it caches static assets, API responses, or provides an offline fallback.

Fix

Add a service worker registration call and implement appropriate caching strategies for static assets and navigation requests.

Explain

Explain how service workers intercept network requests and how different caching strategies trade off freshness vs. speed.

Code Review

Review the service worker file and its registration. Flag missing install/ activate lifecycle handlers, absent cache-versioning, missing fetch handlers, and any patterns that could cause stale content to be served indefinitely.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/performance/service-worker

Câu hỏi thường gặp

Các chiến lược lưu đệm chính là gì?

Skill nêu cache-first, network-first và stale-while-revalidate, và gợi ý chọn một cách cho mỗi loại tài nguyên.

Vì sao phải dọn cache cũ?

Bước activate xóa các tệp đã lưu cũ, để khách truy cập không tiếp tục thấy phiên bản cũ sau khi cập nhật.

Nội dung cũ có gây vấn đề không?

Có. Skill cảnh báo một số mẫu lưu đệm có thể tiếp tục phục vụ nội dung cũ vô thời hạn, nên agent cần rà soát chúng cẩn thận.

Chi tiết

Mô tả gốc của tác giả

Use when auditing repeat-visit performance, adding offline support, or evaluating PWA readiness for a web application.

repo: thedaviddias/Front-End-Checklist

Độ phổ biến

Sao GitHub
75k
Vị trí xếp hạng
#3016
Giấy phép
MIT
Cập nhật
31/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự