Category: HTTP Headers
Description
GET operations should include caching headers (Cache-Control, Expires, or Pragma) in their responses to support proper HTTP caching behavior.
What It Checks
This rule examines GET operations and their 2XX responses for caching header definitions:
Cache-Control- Primary caching directiveExpires- Legacy expiration headerPragma- HTTP/1.0 compatibility
Why It Matters
Proper caching headers enable:
- Performance: Reduced server load and faster responses
- Bandwidth Savings: Clients can use cached responses
- Scalability: Better resource utilization
- User Experience: Faster page loads for cached resources
Examples
Good
paths:
/users:
get:
operationId: getUsers
responses:
'200':
description: List of users
headers:
Cache-Control:
schema:
type: string
description: Caching directive
content:
application/json:
schema:
type: array
Bad
paths:
/users:
get:
operationId: getUsers
responses:
'200':
description: List of users
# No caching headers defined
content:
application/json:
schema:
type: array
Exceptions
- Non-GET operations (POST, PUT, etc.)
- Operations returning sensitive data that shouldn't be cached
- Real-time data endpoints
Configuration
This rule has no configuration options. It is either enabled or disabled.
Related Rules
- Rule 58: Last-Modified - Last modification timestamp
- Rule 59: ETag Headers - Entity tag for caching
- Rule 60: Conditional PUT - Conditional request support