Cache-Control
HTTP caching can dramatically reduce API latency and server load.
Cache-Control: max-age=60 allows a response to be considered fresh for 60 seconds. Other directives include private, public, no-cache, no-store, must-revalidate, and s-maxage.
no-cache does not mean "never store". It means the stored response must be revalidated before reuse. no-store instructs caches not to store the response.
Caching must be designed with authorization and data sensitivity in mind.
Cache Directives
max-age=60:
Fresh for 60 secondsAllows reuse while the response remains fresh.
no-store:
Do not storeUseful for sensitive responses that should not be cached.
private:
Private cache onlyPrevents shared caches from storing the response.
no-cache:
Revalidate before reuseThe response may be stored but must be validated before reuse.