Introduction
This article is a continuation of my previous article of API management in an Azure. From this article, I will explain about the operations of API management in an Azure and from this, it can be configured for Response Caching. Thus, reduces API latency and bandwidth consumption with Web Service load data. This article also explains about adding a Response Caching for API for sample echo API processes.
Prerequisites
- An active Azure subscription.
- Active API management Service in Azure portal and for creating the Azure API management you can click the following link http://www.c-sharpcorner.com/article/managing-api-in-azure/
Configuring Caching
Step 1
Login to your Azure portal.
Step 2
For getting started with adding Caching memory of API, click Publisher portal and it directs to API management portal.
Step 3
Click APIs in API management menu and select echo API.
Step 4
Click operations tab and select GET resource (cached) in an operation list.
Step 5
Select the caching tab for the cache settings for the process.
Step 6
To enable the cache operations, select enable check box & the operations of the values, which varies by headers fields and the duration will be the default values.
Step 7
Click Policies from API management on the left side of the menu and select echo API. Get resource (cached) and the codings, which I have provided in the policy defintion.
- <policies>
- <inbound>
- <base />
- <cache-lookup vary-by-developer="false" vary-by-developer-groups="false">
- <vary-by-header>Accept</vary-by-header>
- <vary-by-header>Accept-Charset</vary-by-header>
- </cache-lookup>
- <rewrite-uri template="/resource" /> </inbound>
- <outbound>
- <base />
- <cache-store caching-mode="cache-on" duration="3600" /> </outbound>
- </policies>
Step 8
For the cache in an action, we should call the operation from the developer portal and select Developer portal in top menu.
Step 9
Click APIs in menu and select echo API.
Step 10
Select code samples as per your desire and click open console.
Step 11
Click Try it in echo API resource (cached).
Step 12
The response content will be displayed with the code sample API and the operation results are keyed by the query string.