Cache

Response messages from the service to its consumers are explicitly labeled as cacheable or non-cacheable. This way, the service, the consumer, or one of the intermediary middleware components can cache the response for reuse in later requests.

The Cache constraint builds upon Client-Server and Stateless with a requirement that responses are implicitly or explicitly labeled as cacheable or non-cacheable. Requests are passed through a cache component, which may reuse previous responses to partially or completely eliminate some interactions over the network (Figure 1. This form of elimination can improve efficiency and scalability, and can further improve user-perceived performance by reducing the average latency during a series of interactions. A common reason for incorporating caching as a native part of a REST architecture is as a counterbalance to some of the negative impacts of applying the Stateless constraint.

Cache: Responses may be cached by the consumer to avoid resubmitting the same requests to the service. This diagram depicts a consumerside cache. REST services can also use serviceside caches for scalability purposes.

Figure 1 - Responses may be cached by the consumer to avoid resubmitting the same requests to the service. This diagram depicts a consumer-side cache. REST services can also use service-side caches for scalability purposes.