api-response-optimization

Optimizes API responses through sparse fieldsets, HTTP caching headers, and compression middleware.

Updated Jun 22, 2026
One-click install
npx skills add https://github.com/aicodepro/ai-agent-nexi --skill api-response-optimization-aicodepro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-response-optimization
Source: https://github.com/aicodepro/ai-agent-nexi/tree/main/agent/skills/api-response-optimization
Command: npx skills add https://github.com/aicodepro/ai-agent-nexi --skill api-response-optimization-aicodepro

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires compression.

What problem does it solve? Slow API responses and oversized payloads degrade user experience and inflate bandwidth costs. This Skill provides concrete patterns for reducing payload sizes, implementing HTTP caching, and enabling response compression in Node.js/Express APIs. ## Core Features & Use Cases - Sparse Fieldsets: Let clients request only the fields they need via query parameters (e.g., GET /users?fields=id,name,email), cutting payload size dramatically. - HTTP Caching with ETags: Generate ETag hashes and return 304 Not Modified responses so clients reuse cached data instead of re-downloading unchanged resources. - Response Compression: Enable gzip/brotli compression middleware with configurable levels and filters to shrink responses over 1KB. - Use Case: Your Express API returns 500KB user payloads with 500ms response times. Apply sparse fieldsets, ETag caching, and compression to reach the documented targets of under 100ms response times and under 50KB payloads. ## Quick Start Ask the assistant to optimize your Express API endpoints by adding sparse fieldsets, ETag caching headers, and compression middleware.

Frequently Asked Questions about api-response-optimization

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

FAQPage Schema
How do I reduce API response payload size in Express?

Implement sparse fieldsets so clients select only needed fields via query parameters like GET /users?fields=id,name,email. Combine this with gzip compression middleware and pagination for collections to cut payloads from hundreds of KB to under 50KB.

How to implement ETag caching in a Node.js API?

Generate an MD5 hash of the response body and send it as the ETag header with a Cache-Control directive. On subsequent requests, compare the client's If-None-Match header and return a 304 Not Modified status when the content is unchanged.

What compression level should I use for API responses?

The compression middleware level 6 balances speed and compression ratio for most APIs. Only compress responses larger than 1KB, and respect an x-no-compression header so clients can opt out when needed.

When should I use short versus long cache TTLs?

Cache immutable resources aggressively with long max-age values, and use short TTLs for frequently changing data. Always invalidate the cache on writes so clients never receive stale data after updates.

Why is my API still slow after adding caching?

Caching only helps repeated requests for unchanged data. Check for N+1 database queries by eager loading related records, remove unnecessary fields from responses, and profile with APM tools before optimizing further.