4.9.3. Caching and Application Semantics
4.9.3. Caching and Application Semantics
When designing an application that uses HTTP, it's important to consider how caching interacts with the application's semantics.
For example, if an application defines a resource that represents a list of items, and items can be added or removed, the application needs to consider:
-
How long should a cached list be considered fresh?
-
What happens if a client makes a decision based on a cached list that's out of date?
-
Should the application use cache invalidation mechanisms to notify caches when the list changes?
Applications SHOULD design their resource representations and caching strategies to work well together. This might involve:
-
Choosing appropriate freshness lifetimes based on how often resources change.
-
Using conditional requests to allow efficient validation.
-
Providing cache invalidation mechanisms (e.g., using
Cache-Control: no-cachefor resources that change frequently). -
Designing resources so that they're naturally cacheable (e.g., making resources immutable where possible).