HTTP caching
When the topic of performance optimization is evoked, caching is often the first technique that comes to mind. Such a technique can be applied to different layers of a web service. In this section, we will focus on leveraging HTTP caching to improve performance. Chapter 10, Scaling a RESTful Web Service, discusses other forms of caching.
Cache-Control
Cache-Control directives are supported by HTTP to prevent unnecessary round trips between clients and servers. After all, the best way to reduce request latency is to not have to contact the server to fetch the response. These directives define who can cache responses, under which conditions, and for how long.
Private/Public caching
If, for example, a resource can safely be cached on the client for a period of time, service designers can choose to set the Cache-Control header to indicate such behavior.
Service designers must select if the caching is either private or public. They can do so by setting the appropriate value in the Cache...