Where to find details of APIM built-in cache and default settings

Syed, Umair 25 Reputation points
2023-06-06T23:58:14.16+00:00

Can I find any detailed doc about the built-in default caching of APIM and what are the default settings if we are not applying any policies on our APIs and rely on the default caching? we have seen improved performance since we have started using APIM but our client needs to know why. why the document says its 'volatile' and how does it get refreshed and ensure there will be no stale data?

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,217 questions
Azure
Azure
A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.
1,011 questions
{count} votes

Accepted answer
  1. navba-MSFT 26,245 Reputation points Microsoft Employee
    2023-06-07T05:34:48.62+00:00

    @Syed, Umair Welcome to Microsoft Q&A Forum, Thank you for posting your query here!

    I understand that you need documentation about the default APIM cache policy and queries around this.

    Firstly, the Azure API Management service has built-in support for HTTP response caching using the resource URL as the key. The key can be modified by request headers using the vary-by properties. This is useful for caching entire HTTP responses from backend API.

    The built-in cache in APIM is designed to improve performance by reducing the number of requests that are sent to the backend API. When a request is received by APIM, it checks the cache to see if it has a cached response for the request. If a cached response is found, APIM returns the cached response instead of forwarding the request to the backend API.

    By default, the built-in cache in APIM has a short expiration time. This means that if a response is cached, it will only be stored in the cache for short duration before it is evicted. This helps to ensure that the cache does not contain stale data.

    Regarding your query about the built-in cache is volatile, It means that the cache can be cleared periodically during API Management updates or if the expiration time is reached.

    Currently the below caching policies are available in APIM:

    Please refer the below documentation for the APIM cache performance improvements:

    https://learn.microsoft.com/en-us/azure/api-management/api-management-howto-cache***

    https://learn.microsoft.com/en-us/azure/api-management/api-management-sample-cache-by-key

    Hope this answers. If you have any follow-up questions on this. Please do get back to us. We would be happy to help.


    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Sedat SALMAN 14,140 Reputation points MVP
    2023-06-07T04:56:19.4433333+00:00

    as a reference you can follow

    https://learn.microsoft.com/en-us/azure/api-management/api-management-howto-cache

    Azure API Management (APIM) includes built-in caching functionality that can significantly reduce latency for API callers and reduce backend load for API providers. The cache is shared by all units in the same region in the same API Management service and is described as 'volatile'. This term indicates that the cache might not be permanent and could be cleared under certain circumstances, such as a restart or a memory pressure situation on the server.

    The built-in cache works based on a cache-lookup and cache-store mechanism. When a request is made to an API operation, the response from the backend service is stored in the cache and keyed by the specified headers and query string parameters. Subsequent calls to the operation with matching parameters return the cached response until the cache duration interval has expired. The duration attribute specifies the expiration interval of the cached responses​.

    When you're not applying any explicit caching policies to your APIs, it's likely that APIM is still leveraging its built-in caching to improve performance. As for ensuring there is no stale data, the cache duration interval determines how long the cached responses are retained before they expire and are refreshed with new data from the backend service.

    If for any reason a cache-related operation fails to connect to the cache (e.g., due to the cache's volatility), the API call using the cache-related operation doesn't raise an error, and the cache operation completes successfully. However, in the case of a read operation, a null value is returned to the calling policy expression, meaning that the data is fetched anew from the backend service. Therefore, the design of your policy code should include a "fallback" mechanism to retrieve data not found in the cache​<sup>.</sup>

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.