Caching is the process of storing the data or response in temporary storage or RAM (Random Access Memory). The temporary storage provides faster access to the data which improves overall system performance and minimizes the load on backend services. Different websites and applications use caches to provide fast site reload.
While storing the data, the API gateway uses in-memory storage or RAM (Random Access Memory). It generally provides fast and temporary storage for data that is frequently used. So storing response RAM can provide fast retrieval of data which is well suitable for caching purposes.
In the API gateway from the policy tab, you can select the caching option and configure a caching policy for a particular API endpoint. When caching is enabled, the gateway caches the response from the backend server after sending the first request to the server. After this, all the requests are served by the cached response of the gateway. Consequently, this reduces the load on servers as well as reduces response time, resulting in a better user experience.
The API gateway can send the response from the cache instead of servers for mentioned TTL time. The TTL time is defined in seconds and it decides how long the cached response will remain valid before it expires.
After completion of this expiration time, the response is sent from the server once and the process repeats. Users can also set the Cache-Control header while sending a response back from the API gateway.