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 ...

Get Building a RESTful Web Service with Spring now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.