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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.didomi.io/api-and-platform/introduction/caching.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
