API responses specify appropriate caching behavior
Why it matters
An API endpoint that returns product listings or blog posts without a Cache-Control header causes every client request to hit the origin server — even when the data hasn't changed in hours. At scale, this is avoidable server load that accumulates into real infrastructure cost and latency. Conversely, a user-specific endpoint (account data, cart, session) served with Cache-Control: public allows CDN or browser caching to serve one user's data to another — a privacy violation. ISO 25010 performance-efficiency.resource-utilization applies: public data should be cached to eliminate redundant computation; private data must be protected from shared caches.
Severity rationale
Low because missing API cache headers waste server resources on repeated identical requests, but the impact is gradual and does not block functionality until traffic scales.
Remediation
Add explicit Cache-Control headers to all API GET routes. Public data (product lists, blog posts, public stats) should be cached; user-specific data (account info, cart, orders) must be marked private or uncacheable.
// Next.js App Router — src/app/api/products/route.ts
export async function GET() {
const products = await db.products.findAll()
return Response.json(products, {
headers: {
'Cache-Control': 'public, s-maxage=3600, stale-while-revalidate=86400'
// CDN caches for 1 hour, serves stale for 24h while revalidating
}
})
}
// User-specific data — must be private
export async function GET(request: Request) {
const user = await getAuthenticatedUser(request)
return Response.json(user, {
headers: {
'Cache-Control': 'private, no-cache'
// Never cache in shared (CDN) cache
}
})
}
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Performance & Load Readiness Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · performance-efficiency.resource-utilization — Resource Utilization
Taxons
History
- 2026-04-18·v1.0.0·Initial import from performance-load·automated