API Response Compressor
When to Trigger
- •Large API responses (>100 KB)
- •High-traffic endpoints
- •"Optimize API"
What to Do
- •Select: Return only needed fields (Prisma select); avoid deep include of unused relations.
- •Pagination: Enforce limit and offset/cursor; return meta (total, page, hasMore).
- •Compression: Enable gzip/brotli in Next.js or hosting; set Content-Encoding when applicable.
- •Headers: Cache-Control for cacheable responses (e.g. s-maxage, stale-while-revalidate).
Don’t break existing clients; add fields optionally (e.g. ?fields=) if needed. Measure response size before/after.