api-caching

Implement HTTP caching strategies with Cache-Control, ETags, and Redis.

6|1|Updated Feb 27, 2026
One-click install
npx skills add https://github.com/RepairYourTech/cfsa-antigravity --skill api-caching-repairyourtech
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-caching
Source: https://github.com/RepairYourTech/cfsa-antigravity/tree/main/.agent/skill-library/surface/api/api-caching
Command: npx skills add https://github.com/RepairYourTech/cfsa-antigravity --skill api-caching-repairyourtech

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the critical need to improve API response times, reduce server load, and manage data freshness by implementing robust HTTP caching strategies.

Core Features & Use Cases

  • HTTP Caching Headers: Configure Cache-Control, ETag, Last-Modified, and Vary headers for effective client and CDN caching.
  • CDN Invalidation: Implement strategies like surrogate keys and path purging for timely cache updates.
  • Application-Level Caching: Utilize Redis or in-memory stores for granular data caching and invalidation.
  • Use Case: Optimize a product catalog API by implementing s-maxage for CDN caching, stale-while-revalidate for near-instant responses, and surrogate keys for efficient invalidation when product details change.

Quick Start

Configure the API response to cache for 1 hour publicly, with a 5-minute CDN cache and background revalidation.

Frequently Asked Questions about api-caching

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

FAQPage Schema
How do I implement HTTP caching headers for API performance optimization?

API performance optimization with HTTP caching headers involves configuring `Cache-Control`, `ETag`, `Last-Modified`, and `Vary` to manage client and CDN caching effectively. This reduces server load and improves response times by enabling conditional requests.

What is the best way to invalidate CDN cache when API data changes?

CDN cache invalidation is best handled using surrogate keys or path purging to ensure timely cache updates. Surrogate keys allow targeted invalidation of specific content groups when underlying API data changes, avoiding full cache flushes.

How does Redis application-level caching differ from HTTP caching for APIs?

Redis application-level caching provides granular data caching and invalidation at the server level, whereas HTTP caching uses headers like `Cache-Control` for client and CDN caching. Redis is ideal for caching database queries or complex computations.

When do I need Vary headers for API caching?

Vary headers are needed for API caching when responses differ based on request headers like `Accept-Encoding` or `Authorization`. Adding `Vary` ensures CDNs and clients cache distinct representations correctly, preventing serving wrong content variants.

Can I use stale-while-revalidate for near-instant API responses?

Yes, you can use `stale-while-revalidate` for near-instant API responses by allowing caches to serve stale content while fetching a fresh copy in the background. This strategy drastically reduces latency for users while maintaining data freshness.