- Home
- Skills
- Secondsky
- Claude Skills
- Api Response Optimization
api-response-optimization_skill
- TypeScript
52
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill secondsky/claude-skills --skill api-response-optimization- SKILL.md2.0 KB
Overview
This skill optimizes API performance by reducing payloads, applying caching strategies, and enabling response compression. It provides practical techniques like sparse fieldsets, HTTP caching headers, and gzip/brotli compression to lower latency and bandwidth. The goal is measurable improvement in response time, payload size, and server load for production APIs.
How this skill works
The skill inspects API responses and suggests or applies changes to reduce unnecessary data, such as removing sensitive fields and implementing sparse fieldsets. It adds HTTP caching (ETag, Last-Modified, Cache-Control) to avoid redundant work and configures compression middleware with sensible defaults. It also recommends pagination, eager loading to avoid N+1 queries, and monitoring targets to validate improvements.
When to use it
- When API response times are high and you need tangible latency reductions.
- When bandwidth costs are significant or clients see large payloads.
- When you want to add or improve caching to reduce repeated processing.
- When serving large collections without pagination or sparse selection.
- Before scaling infrastructure — to get more capacity from existing servers.
Best practices
- Remove sensitive and unnecessary fields from responses to reduce payload and exposure.
- Expose sparse fieldsets so clients request only the fields they need.
- Set ETag or Last-Modified plus Cache-Control for immutable resources.
- Enable gzip/brotli compression for responses larger than ~1KB and tune compression level for CPU tradeoffs.
- Use pagination and server-side cursors for large collections and eager load relations to avoid N+1 queries.
- Monitor with APM and define performance targets before and after changes.
Example use cases
- A product API adds ETag and returns 304 responses for unchanged resources to cut server load.
- A user endpoint implements ?fields=id,name,email to deliver minimal payloads for mobile clients.
- Enabling compression on HTML and JSON responses to reduce bandwidth and improve page load times.
- Applying pagination and eager loading to a social feed to eliminate N+1 queries and reduce response size.
- Setting short TTLs for dynamic data and long TTLs for immutable assets to balance freshness and cache hit rate.
FAQ
Not always — compression reduces transfer time but increases CPU. Test different compression levels and enable it for payloads that benefit most, typically >1KB.
When should I use ETag vs Last-Modified?
ETag is preferred for precise change detection; Last-Modified is simpler but less accurate for small or frequent updates. Use ETag for complex objects.