Azure API Management - Internal cache

Ravi Kiran 1 Reputation point
2022-03-02T18:40:57.773+00:00

Hi, I am in a process of exploring Azure API Management for our project and tried looking for below questions over the internet but couldn't get to a conclusive information. I am using internal cache and API Management is not geo replicated

Is there a way I can find out cache key for my API, which I can invalidate at any point of time if needed before specified elapse time.
or
Is there a way I can invalidate all the cache at once in the instance
or
Can I specify a custom cache key to the API where I will have handle to invalidate when needed

Thank you in Advance for helping me out!!!

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,785 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MayankBargali-MSFT 69,156 Reputation points
    2022-03-03T12:52:57.767+00:00

    @Ravi Kiran Thanks for reaching out. I believe you might be already looked into the Azure APIM cache policy document but sharing the same for the community members.
    You can leverage the APIM management REST API to perform supported operations on APIM. You can refer to the cache REST document for the operation supported for APIM cache.

    Is there a way I can find out cache key for my API, which I can invalidate at any point of time if needed before specified elapse time.
    You can leverage the List by Service API to list all the caches created for your APIM instance and to invalid/delete the cached you can call the Delete operation

    Is there a way I can invalidate all the cache at once in the instance
    Yes, you need to first call the List by Service API and loop in through all the return cache array, and call the Delete Operation on the individual cache.

    Can I specify a custom cache key to the API where I will have handle to invalidate when needed
    Whenever you create the cache within the policy then you need to assign the cache key. If your requirement is that based on input body/parameter while calling the APIM API you want to delete/invalid the cache then yes you need to write your custom logic in your policy to handle this. You can leverage the C# expression in your policy to handle it. Now to invalid the cache you need to leverage the Send request policy to create the HTTP request to invalid/delete the cache as per your business requirement.

    To get familiar with the Azure REST API you can refer to this document.

    1 person found this answer helpful.