jiayaoqijia/cryptoskill/0xklen-cache-with-service-worker
Claude Code and agent skill by jiayaoqijia/cryptoskill
- community
Checking that the SKILL.md file is still in the repository.
Use when repeat visits should be offline-capable and instant. Precaches app shell assets with Workbox and serves data with stale-while-revalidate.
Install
npx vskill@latest install jiayaoqijia/cryptoskill/0xklen-cache-with-service-workerSKILL.md
The same SKILL.md was published earlier as jiayaoqijia/cryptoskill/0xklen-cache-with-service-worker.
Cache with a Service Worker
A service worker is the only way to make a repeat visit paint from disk in under 100 ms. It also gives you a cache you can corrupt, so versioning discipline is the whole job.
Procedure
- Generate the precache manifest at build time so every hashed asset is listed, not hand-typed:
npx workbox-cli generateSW workbox-config.js
- Set the strategy per route: precache the app shell,
stale-while-revalidatefor GET API data,network-firstfor volatile config,cache-firstfor immutable static hashes. - Cap cache growth so a long-lived user does not fill the disk quota:
workbox.routing.registerRoute(({request}) => request.destination === 'image', new workbox.strategies.CacheFirst({cacheName: 'imgs', plugins: [new workbox.expiration.ExpirationPlugin({maxEntries: 80, maxAgeSeconds: 30243600})]}));
- Beat the 24-hour cache update rule: ship a small
sw.jsthat changes each deploy (a build hash in a comment) so the browser byte-compares and updates. - Handle the
activatelifecycle by deleting caches whose name is not in the current list; otherwise old shells accumulate. - Guard
skipWaiting/clients.claimbehind an explicit reload prompt so users are not swapped mid-session.
Pitfalls
- Precaching before hashing is applied, so the manifest lists stale filenames and every fetch misses.
- Deleting all caches in
activatewithout excluding the newly created one, blanking the offline page. - A cache-first strategy on
/api/returning yesterday's prices forever. - Forgetting that the SW intercepts navigation, so a bad deploy serves a cached 200 for a route that now 404s.
- No cache size cap, letting a chatty image route quietly exhaust the origin quota and evict everything.
Verification
# DevTools -> Application -> Service Workers: reload twice offline curl -sI https://shop.example.com/sw.js | grep -i 'cache-control'
sw.js must be served no-cache so the browser can byte-check it. Report the precache entry count and a cold-reload repeat-visit timing from the Network panel.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/payments/0xklen-cache-with-service-worker/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/jiayaoqijia/cryptoskill/0xklen-cache-with-service-worker)