
Api Response Optimization
Solid fundamentals for making your API responses lighter and faster. You get sparse fieldsets so clients can request only the fields they need, ETag-based caching to avoid sending unchanged data, and compression middleware setup. The performance targets are ambitious but realistic: sub-100ms responses, payloads under 50KB, and significantly reduced CPU usage. The checklist covers the usual suspects like pagination and N+1 prevention. Nothing groundbreaking here, just the standard optimizations you should be doing anyway but probably aren't. Good reference if you're debugging slow endpoints or getting complaints about mobile data usage.
- skills.sh installs
- 434
- GitHub stars
- 248
- last updated
- Aug 21, 2026
Install
$ npx -y skills add secondsky/claude-skills --skill api-response-optimization --agent claude-codeInstalls into .claude/skills of the current project.
Files
API Response Optimization
Reduce payload sizes, implement caching, and enable compression for faster APIs.
Sparse Fieldsets
// Allow clients to select fields: GET /users?fields=id,name,email
app.get('/users', async (req, res) => {
const fields = req.query.fields?.split(',') || null;
const users = await User.find({}, fields?.join(' '));
res.json(users);
});
HTTP Caching Headers
app.get('/products/:id', async (req, res) => {
const product = await Product.findById(req.params.id);
const etag = crypto.createHash('md5').update(JSON.stringify(product)).digest('hex');
if (req.headers['if-none-match'] === etag) {
return res.status(304).end();
}
res.set({
'Cache-Control': 'public, max-age=3600',
'ETag': etag
});
res.json(product);
});
Response Compression
const compression = require('compression');
app.use(compression({
filter: (req, res) => {
if (req.headers['x-no-compression']) return false;
return compression.filter(req, res);
},
level: 6 // Balance between speed and compression
}));
Performance Targets
Sponsors
Details
- Repository
- github.com/secondsky/claude-skills
- Categories
- Backend & APIs, Debugging
- First seen
- Jun 3, 2026
More from secondsky/claude-skills
All 146- Api Pagination433
- Api Filtering Sorting432
- Defense In Depth Validation430
- Session Management427
- Ultracite426
- Nuxt Production425
- Api Gateway Configuration422
- Oauth Implementation422
- Nuxt Ui V4421
- Health Check Endpoints420
- Cloudflare D1416
- Api Changelog Versioning415
- Dependency Upgrade415
- Idempotency Handling415
- Nuxt Server415
- Turborepo414
- Mobile Offline Support412
- Recommendation System412
- Api Versioning Strategy410
- Claude Code Bash Patterns408
- Claude Hook Writer408
- Logging Best Practices408
- Cloudflare Manager407
- Plan Interview406