Command Palette

Search for a command to run...

Назад к скиллам
скилл № 24036

frontend-browser-caching

Use when the user asks about Cache-Control headers, ETag, immutable hashed assets, cache busting, stale-while-revalidate, bfcache or service worker cache…

БесплатноБез исполняемых скриптов
j4flmaoот j4flmao★ 47 звёзд на GitHub

Установить frontend-browser-caching в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Browser Caching

Purpose

Optimize load performance via HTTP cache headers, service worker caching, and stale-while-revalidate. Minimize network round-trips while serving fresh content. First load under 2s, repeat loads under 500ms. Full offline support for static assets.

Agent Protocol

Trigger

Exact user phrases: "browser caching", "cache headers", "service worker", "SW", "stale-while-revalidate", "SWR", "cache strategy", "Cache-Control", "ETag", "cache busting", "offline caching".

Input Context

Before activating, verify:

  • Whether the focus is HTTP cache headers, service worker, or both.
  • The build tool (Vite, Webpack, Next.js) for cache-busting config.

Output Artifact

No file output. Produces caching strategy, header configs, or service worker code as text.

Response Format

Resource: {type}
Strategy: {cache strategy}
Config: {code block}

No preamble. No postamble. No explanations. No filler/hedging/transitions. Compress output.

Completion Criteria

  • Static assets use Cache-Control: public, max-age=31536000, immutable.
  • HTML uses Cache-Control: no-cache for freshness validation.
  • API responses use appropriate Cache-Control or ETag.
  • Service worker registers and caches static assets on install.
  • Stale-while-revalidate pattern for data fetching.
  • Cache-busting via content hashes in filenames.

Max Response Length

4096 tokens.

Component Architecture / Decision Trees

Cache Strategy Decision Tree

Resource type?
  |-- Static asset (JS, CSS, image, font) -->
  |     |-- Content-hashed filename?
  |     |     |-- YES --> Cache-Control: public, max-age=31536000, immutable
  |     |     |-- NO  --> Add content hashing to build tool
  |-- HTML page -->
  |     |-- Static / pre-rendered? --> Cache-Control: public, max-age=300 (5 min), ETag
  |     |-- Dynamic / user-specific? --> Cache-Control: no-cache, private
  |-- API response -->
  |     |-- Public / shareable? --> Cache-Control: public, max-age=60, stale-while-revalidate=600
  |     |-- User-specific? --> Cache-Control: private, no-cache
  |-- Third-party resource -->
        |-- CDN-hosted? --> Use the CDN's cache headers, add integrity hash

Cache Location Decision Tree

Where should the response be cached?
  |-- Browser (private cache) -->
  |     |-- Static asset: Cache-Control: private, max-age=31536000
  |     |-- Auth response: Cache-Control: private, no-cache
  |-- CDN / proxy (shared cache) -->
  |     |-- Public page: Cache-Control: public, s-maxage=3600, max-age=60
  |     |-- API response: Cache-Control: public, s-maxage=300
  |-- Service worker -->
        |-- Install-time: Precache all versioned assets
        |-- Runtime: Stale-while-revalidate for API + HTML

Cache Invalidation Decision Tree

Content changed — how to invalidate?
  |-- Static asset changed -->
  |     |-- Content hash in URL? --> New URL = automatic invalidation
  |     |-- No hash? --> Versioned path (/v2/asset.js) or query string (?v=2)
  |-- API response changed -->
  |     |-- Use ETag? --> Conditional request validates freshness
  |     |-- No ETag? --> Short max-age or no-cache
  |-- HTML page changed -->
        |-- Use revalidation? --> no-cache + ETag = instant freshness check
        |-- Use CDN? --> Purge CDN cache for that path

Service Worker Architecture Options

Option A: Cache-first for static assets, network-first for HTML Best for: Content-heavy sites where assets change rarely. Provides offline capability.

Install: precache all static assets
Fetch: serve from cache, update in background (stale-while-revalidate)
HTML: network first, fallback to cache
API: stale-while-revalidate

Option B: Network-first with cache fallback Best for: Dynamic apps where freshness is critical (dashboards, admin panels).

Install: precache shell (minimal HTML, CSS, JS)
Fetch: HTML and API always from network
Static assets: cache-first
Fallback: cached offline page

Option C: Offline-first (fully cached) Best for: Progressive Web Apps that must work entirely offline.

Install: precache everything needed for full functionality
Fetch: cache-first for all resources, periodic background sync
API: IndexedDB local cache with background sync when online

Workflow

Step 1: HTTP Cache Headers by Resource Type

# Static assets (JS, CSS, images, fonts)
Cache-Control: public, max-age=31536000, immutable

# HTML pages
Cache-Control: no-cache
ETag: "abc123"

# API responses
Cache-Control: public, max-age=60, stale-while-revalidate=600

# User-specific content
Cache-Control: private, no-cache

Step 2: Service Worker Install & Cache

const CACHE_NAME = 'static-v1'
const STATIC_ASSETS = [
  '/',
  '/index.html',
  '/app.js',
  '/app.css',
  '/logo.png',
]

self.addEventListener('install', (event) => {
  event.waitUntil(
    caches.open(CACHE_NAME).then((cache) => cache.addAll(STATIC_ASSETS))
  )
  self.skip
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • references/cache-invalidation-strategies.md
  • references/cache-strategies.md
  • references/caching-headers.md
  • references/caching-strategies.md
  • references/local-storage-strategies.md
  • references/service-worker-caching.md
  • references/sw-caching.md

FAQ

Что делает скилл frontend-browser-caching?

Use when the user asks about Cache-Control headers, ETag, immutable hashed assets, cache busting, stale-while-revalidate, bfcache or service worker cache strategies for page loads. Produces browser caching headers and asset versioning rules. Not for installable offline apps (use frontend-pwa) or CDN edge config (use cdn-edge).

Как установить скилл frontend-browser-caching?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл frontend-browser-caching запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить frontend-browser-caching с