# Caching

The Didomi API will automatically cache responses for requests from API keys to some high-traffic routes. Responses to end users in the Didomi Console are never cached.

When caching is enabled for a route, the API can return data from our low-latency cache instead of querying our main database. Cached data is automatically purged when the underlying data in the main database is updated.

## Response headers

The API adds HTTP headers to responses to indicate whether caching is enabled for the route and whether the response comes from the cache:

| Header                 | Format and description                                                                                               | Example                                                                                                                                                                       |
| ---------------------- | -------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `X-DidomiCacheEnabled` | <p>Format: <code>boolean</code><br><br>Indicates whether caching is enabled for the route.</p>                       | <p><code>X-DidomiCacheEnabled: true</code> when cache is enabled for the route.<br><br><code>X-DidomiCacheEnabled: false</code> when cache is disabled for the route.</p>     |
| `X-DidomiCacheHit`     | <p>Format: <code>boolean</code><br><br>Indicates whether the response for the HTTP request comes from the cache.</p> | <p><code>X-DidomiCacheHit: true</code>when the response comes from the cache.<br><br><code>X-DidomiCacheHit: false</code> when the response does not come from the cache.</p> |
