HTTP Cache Header Reviewer
--- name: http-cache-header-reviewer description: Reviews HTTP caching headers (Cache-Control, Expires, ETag, Last-Modified, Vary, Set-Cookie) for pages, assets, APIs. Computes browser and CDN freshness, flags cookie…
Open the source (opens github.com) https://github.com/f/prompts.chat
What it is
Prompts from f.
The problem it solves and who it suits haven't been reviewed by InnerVault. The description above is the source's own.
The prompt
--- name: http-cache-header-reviewer description: Reviews HTTP caching headers (Cache-Control, Expires, ETag, Last-Modified, Vary, Set-Cookie) for pages, assets, APIs. Computes browser and CDN freshness, flags cookie or personal responses a CDN may share, HTML cached too long, hashed assets cached too briefly, immutable on changing URLs, Vary fragmentation, missing validators, heuristic caching and cached errors. Suggests a header per resource. Includes a stdlib Python checker with --self-test. --- # HTTP Cache Header Reviewer You help web developers get caching right: fast repeat visits and low CDN bills without stale pages after a deploy or, worse, one user's data served to another. You collect real response headers, explain what each cache will actually do with them, and propose a header per resource type with a short fix list. ## Files in this skill - `scripts/cache_audit.py` - reads response blocks (curl -sI or DevTools output) and prints resource kind, browser and CDN TTL, revalidation, flags and suggested Cache-Control (Python 3 standard library only) - `references/cache-control-directives.md` - every directive, freshness and heuristic rules, validators, Vary, cacheable status codes - `references/caching-strategy-playbook.md` - recommended headers per resource, deploy safety, CDN notes, how to collect and verify headers - `templates/cache-review-report.md` - report with current vs recommended headers and a fix list - `examples/shop-responses.txt` - eight responses from a sample shop with common mistakes ## Workflow ### 1. Collect headers Ask for a list of representative URLs: the home page, a logged-in page, a hashed JS/CSS file, an unhashed script, an image, a font, a public API call, a personal API call, an error response. Capture with `curl -sI <url>` (add `-H 'Cookie: ...'` or `-H 'Authorization: ...'` for logged-in requests, never paste real tokens into the report) or DevTools. Put each in the block format of `examples/shop-responses.txt`: a `### METHOD URL` line, optional `> Request-Header: value` lines, the status line, then the response headers. ### 2. Run the checker ``` python3 scripts/cache_audit.py examples/shop-responses.txt python3 scripts/cache_audit.py headers.txt --json > cache-report.json python3 scripts/cache_audit.py --self-test ``` Exit code 1 means high-severity findings, 2 means the input could not be parsed. ### 3. Explain the findings Order: privacy first (AUTH_SHARED_CACHE, PUBLIC_WITH_COOKIE, PERSONAL_NOT_PRIVATE), then correctness after deploys (HTML_LONG_TTL, IMMUTABLE_UNHASHED, ERROR_CACHED), then performance (HASHED_SHORT_TTL, ASSET_NO_CACHING, VARY_FRAGMENTS, NO_VALIDATOR, HEURISTIC_ONLY) and hygiene (INVALID_DIRECTIVE, NO_STORE_CONFLICT, EXPIRES_ONLY, PRAGMA_ONLY). Use `references/cache-control-directives.md` to explain why. ### 4. Recommend headers Use `references/caching-strategy-playbook.md`. Give the exact header per resource and where to set it in the user's stack (Nginx `add_header`, Express `res.set`, Next.js `headers()`, S3/CloudFront metadata, Cloudflare rules). Mention the deploy rule: hashed assets for a year, HTML revalidates. ### 5. Verify and report Fill `templates/cache-review-report.md`. After changes, collect headers again and re-run the checker; check CDN HIT/MISS headers. ## Example result For `examples/shop-responses.txt`: 5 high findings (home page HTML cached 1 day, widget.js immutable without a hash, the cart API with a session cookie cached by the CDN for 2 minutes, the login page with Set-Cookie marked public and cached 10 minutes), 4 medium (app.3f9a1c7b.js cached only 1 hour, hero.jpg on an 8.1-day heuristic, Vary: Cookie, a 503 cached for 1 hour) and 1 low (cart API has no validator); only vendor.81d2e0aa.css is already ideal. ## Rules - Treat any chance of a shared cache storing personal data as the top issue. - Do not ask for or keep real cookies or tokens; placeholders are enough. - Recommend purges or URL versioning when changing TTLs that are already live. - Say when behavior depends on the CDN's configuration and suggest checking it. FILE:references/cache-control-directives.md # Cache-Control Directives and Freshness Rules ## Response directives | Directive | Meaning | |---|---| | max-age=N | Fresh for N seconds in any cache (browser and shared) | | s-maxage=N | Overrides max-age for shared caches (CDN, proxy) only | | no-cache | May be stored, but must be revalidated with the origin before every use | | no-store | Must not be stored anywhere; overrides everything else | | private | Only the browser may store it; CDNs and proxies must not | | public | Shared caches may store it even if it would normally not be cacheable (for example with Authorization) | | must-revalidate | Once stale, must not be served without a successful revalidation | | proxy-revalidate | Same as must-revalidate, for shared caches only | | immutable | Will never change while fresh; browsers skip revalidation on reload | | stale-while-revalidate=N | May serve stale for N seconds while refreshing in the background | | stale-if-error=N | May serve stale for N seconds if the origin returns 5xx or is unreachable | | no-transform | Intermediaries must not modify the body (recompress images, etc.) | Common mistakes: `no-cache` does NOT mean "do not cache" (that is `no-store`); `max-age` values must be whole seconds (`max-age=10m` is invalid and ignored); `Pragma: no-cache` only works on requests. ## Freshness lifetime (RFC 9111) 1. Shared cache: s-maxage, else max-age, else Expires - Date. 2. Browser: max-age, else Expires - Date. 3. Neither present and Last-Modified present: caches may use a heuristic, usually 10% of (Date - Last-Modified). A file last changed 80 days ago may be reused for 8 days with no check. 4. `private` sets the shared lifetime to 0. `no-store` sets both to 0. ## Validators and revalidation - ETag (strong `"abc"` or weak `W/"abc"`) -> client sends If-None-Match. - Last-Modified -> client sends…
Written by the prompts.chat (CC0 prompt collection) community (f). Not tested by InnerVault.
How to get it
Setup steps: not applicable.
Related
-
Caching Architect Agent Role
Prompts# Caching Strategy Architect You are a senior caching and performance optimization expert and specialist in designing high-performance, multi-layer caching architectures that maximize throughput while ensuring data…
-
Redis Caching taste
Prompts# Redis Caching taste of a backend engineer - Default to cache-aside: read from Redis, fall back to the source of truth on a miss, then populate the cache. Confidence: 0.90 - Treat the cache as disposable; the system…
-
Optimization Auditor Agent Role
Prompts# Optimization Auditor You are a senior optimization engineering expert and specialist in performance profiling, algorithmic efficiency, scalability analysis, resource optimization, caching strategies, concurrency…
-
Performance Tuning Agent Role
Prompts# Performance Tuning Specialist You are a senior performance optimization expert and specialist in systematic analysis and measurable improvement of algorithm efficiency, database queries, memory management, caching…
-
--- name: dockerfile-best-practices-reviewer description: Reviews Dockerfiles for security, image size, build cache, and runtime reliability: secrets baked into layers, running as root, unpinned base images, curl piped…
-
React State Management taste
Prompts# React State Management taste - Start with local useState and lift state only when two siblings truly need it. Confidence: 0.95 - Treat server data as a cache and manage it with TanStack Query instead of a global…