br-etag-cache

Add HTTP caching to GET and HEAD endpoints with ETag headers.

21|1|Updated Apr 29, 2026
One-click install
npx skills add https://github.com/Lonsdale201/wp-agent-skills --skill br-etag-cache
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: br-etag-cache
Source: https://github.com/Lonsdale201/wp-agent-skills/tree/main/better-route/br-etag-cache
Command: npx skills add https://github.com/Lonsdale201/wp-agent-skills --skill br-etag-cache

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

HTTP GET/HEAD endpoints often re-emit identical responses. This Skill provides HTTP-level caching by emitting ETag headers and validating If-None-Match, enabling conditional requests and reducing bandwidth.

Core Features & Use Cases

  • Emits an ETag header for 2xx responses on GET/HEAD endpoints and returns 304 when If-None-Match matches.
  • Supports a customizable etagResolver to compute a cheap hash from invariant data (e.g., last-modified timestamp, ID).
  • Optional weak validators (W/"hash") to permit semantic equivalence and safe caching with client CDNs.
  • Can be paired with Cache-Control headers to enable true client/CDN caching for read endpoints.

Quick Start

Attach the ETag middleware to GET/HEAD routes and optionally provide a cheap etagResolver or Cache-Control headers to enable client/CDN caching.

Frequently Asked Questions about br-etag-cache

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add HTTP ETag caching to better-route GET endpoints?

To add HTTP ETag caching to better-route GET endpoints, attach the middleware to your read routes. It automatically emits ETag headers for 2xx responses and returns 304 status codes when If-None-Match validators match, reducing bandwidth.

What does an If-None-Match conditional request return when the ETag matches?

An If-None-Match conditional request returns a 304 Not Modified response when the client's ETag matches the server's resource validator. This HTTP caching mechanism prevents re-transmitting identical response bodies, saving bandwidth.

Can I use weak validators for semantic equivalence in HTTP caching?

Yes, you can use weak validators for semantic equivalence in HTTP caching. The middleware supports weak ETag validators (W/"hash") to permit safe caching with client CDNs, allowing equivalent resources to match without requiring byte-for-byte identity.

Does ETag middleware apply to POST or other non-read HTTP methods?

No, ETag middleware does not apply to POST or other non-read HTTP methods. It strictly targets GET and HEAD endpoints, only processing 2xx non-204 responses to ensure write operations remain unaltered.

How do I set Cache-Control headers for CDN caching alongside ETag?

To set Cache-Control headers for CDN caching alongside ETag, pair the middleware with your own Cache-Control directives. This combination enables true client and CDN caching across read endpoints by managing both validation and expiration.

What is a cheap etagResolver and how does it compute ETags?

A cheap etagResolver is a customizable function to compute ETags from invariant data like last-modified timestamps or resource IDs. It generates an efficient hash for HTTP caching, avoiding expensive full response body hashing.