Book Image

RESTful Java Web Services, Second Edition

Book Image

RESTful Java Web Services, Second Edition

Overview of this book

Table of Contents (17 chapters)
RESTful Java Web Services Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Caching RESTful web API results


The ability to cache and reuse previously retrieved resources is essential for improving the performance of a REST application. The HTTP/1.1 protocol specification provides a number of features to facilitate the caching of network resources. These offerings can be leveraged for improving the performance of the RESTful web APIs accessed over the HTTP protocol.

HTTP Cache-Control directive

The HTTP Cache-Control directive defines the HTTP response caching policies. You can use it for enabling the caching of the RESTful web API results for a specified interval. Here is a quick summary of the important HTTP Cache-Control directives:

HTTP Cache-Control directive

Description

Public

In this directive, public resources can be cached by the client and all intermediate public proxies.

private

In this directive, private resources can be cached only by the client.

max-age

This directive specifies how long a resource cached on the client is valid (measured...