4.9. Leveraging HTTP Caching
4.9. Leveraging HTTP Caching
HTTP caching [HTTP-CACHING] is one of the most important features for improving the performance and scalability of applications that use HTTP. Caching allows responses to be stored and reused, reducing the number of requests that need to be sent to the origin server.
Applications using HTTP SHOULD use caching where appropriate. This means:
-
Responses that can be cached SHOULD include appropriate cache directives (e.g.,
Cache-Control). -
Responses that should not be cached SHOULD explicitly indicate this (e.g.,
Cache-Control: no-store). -
Applications SHOULD use conditional requests (e.g., with
If-None-MatchorIf-Modified-Since) to allow caches to validate stored responses.
However, caching introduces complexity. Applications need to carefully consider:
-
What responses can be safely cached and for how long.
-
How to handle cache invalidation when resources change.
-
How to ensure that private or sensitive information isn't cached inappropriately.
-
How to deal with intermediary caches that might not behave as expected.
See [HTTP-CACHING] for detailed information about HTTP caching.