2.11 Caching

Caching enables faster responses from APIs and reduces server load. It is good for information which is frequently requested but does not change very often. The aim is to retrieve information once but re-use many times.

There are a number of caching methodologies available, as discussed in the cache-control headers section ( This section focuses on two types of caching that should be owned and controlled by the provider, primarily for APIs.

2.11.1 Response Cache

A response cache is a cache that contains the response to a GET request on a unique resource. The response should be cached as close to the consumer as possible while remaining inside the control boundaries of the agency. Response caches are usually fast, in-memory caches. Many off the shelf API gateway/management solutions provide a built-in response cache. When using a response cache, agencies should ensure that they understand and monitor their cache to ensure that stale objects are kept to a minimum and that they have sufficient system memory to service caching loads. This means ensuring that the cache is refreshed once a user has updated the information or a cache timeout has occurred.

Consider the following example regarding response cache:

 Illustration of Caching Sequence

2.11.2 Object Cache

An object cache is used to cache objects that are fundamental to the function of an API but may not change on a regular basis. For example, an API may include a tax code validation step. Tax code references are held in a back end database. To prevent redundant requests to the database, the API layer could cache tax codes in its object cache and refer to these until the cache becomes invalid. The diagram below details an example sequence.


Page last updated: 19/12/2016