Skip to content

Commit ad436f4

Browse files
committed
edits
1 parent e8e4cf3 commit ad436f4

File tree

1 file changed

+29
-26
lines changed

1 file changed

+29
-26
lines changed

articles/api-management/api-management-howto-cache.md

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,59 @@
11
---
2-
title: Add caching to improve performance in Azure API Management
2+
title: Add Caching to Improve Performance in Azure API Management
33
description: Learn how to improve the latency, bandwidth consumption, and web service load for API Management service calls.
44
author: dlepow
55
ms.service: azure-api-management
66
ms.topic: how-to
77
ms.date: 05/15/2025
88
ms.author: danlep
9+
10+
#customer intent: As an API developer, I want to use caching so that I can improve performance in API Management.
911
---
1012

1113
# Add caching to improve performance in Azure API Management
1214

1315
[!INCLUDE [api-management-availability-premium-dev-standard-basic-premiumv2-standardv2-basicv2](../../includes/api-management-availability-premium-dev-standard-basic-premiumv2-standardv2-basicv2.md)]
1416

15-
APIs and operations in API Management can be configured with response caching. Response caching can significantly reduce latency for API callers and backend load for API providers.
17+
APIs and operations in API Management can be configured with response caching. Response caching can significantly reduce latency for API callers and backend load for API providers.
1618

1719
> [!IMPORTANT]
18-
> Built-in cache is volatile and is shared by all units in the same region in the same API Management service. Regardless of the cache type being used (internal or external), if the cache-related operations fail to connect to the cache due to the volatility of the cache or any other reason, the API call that uses the cache related operation doesn't raise an error, and the cache operation completes successfully. In the case of a read operation, a null value is returned to the calling policy expression. Your policy code should be designed to ensure that there's a "fallback" mechanism to retrieve data not found in the cache.
20+
> Built-in cache is volatile and is shared by all units in the same region in the same API Management service. Regardless of the cache type being used (internal or external), if cache-related operations fail to connect to the cache because of the volatility of the cache or for any other reason, the API call that uses the cache-related operation doesn't raise an error, and the cache operation completes successfully. In the case of a read operation, a null value is returned to the calling policy expression. Your policy code should be designed to ensure that there's a fallback mechanism to retrieve data that's not found in the cache.
21+
1922
For more detailed information about caching, see [API Management caching policies](api-management-policies.md#caching) and [Custom caching in Azure API Management](api-management-sample-cache-by-key.md).
2023

21-
![cache policies](media/api-management-howto-cache/cache-policies.png)
24+
:::image type="content" source="media/api-management-howto-cache/cache-policies.png" alt-text="Screenshot that shows cache policies in API Management." lightbox="media/api-management-howto-cache/cache-policies.png":::
25+
2226

2327
What you'll learn:
2428

2529
> [!div class="checklist"]
2630
> * Add response caching for your API
27-
> * Verify caching in action
31+
> * Verify that caching is working
2832
2933

3034
> [!NOTE]
31-
> Internal cache is not available in the **Consumption** tier of Azure API Management. You can [use an external Azure Cache for Redis](api-management-howto-cache-external.md) instead. You can also configure an external cache in other API Management service tiers.
35+
> Internal caching isn't available in the **Consumption** tier of Azure API Management. You can [use an external Azure Cache for Redis](api-management-howto-cache-external.md) instead. You can also configure an external cache in other API Management service tiers.
3236
>
3337
34-
35-
3638
## Prerequisites
3739

38-
To complete this tutorial:
39-
4040
+ [Create an Azure API Management instance](get-started-create-service-instance.md)
4141
+ [Import and publish an API](import-and-publish.md)
4242

43-
## Add the caching policies
43+
## Add caching policies
4444

45-
With caching policies shown in this example, the first request to a test operation returns a response from the backend service. This response is cached, keyed by the specified headers and query string parameters. Subsequent calls to the operation, with matching parameters, will have the cached response returned, until the cache duration interval has expired.
45+
With the caching policies shown in this example, the first request to a test operation returns a response from the backend service. This response is cached, keyed by the specified headers and query string parameters. Subsequent calls to the operation, with matching parameters, will return the cached response until the cache duration interval expires.
4646

4747
1. Sign in to the [Azure portal](https://portal.azure.com).
4848
1. Browse to your API Management instance.
49-
1. Select **APIs** > **APIs** from the menu on the left.
49+
1. Select **APIs** > **APIs** in the menu on the left.
5050
1. Select an API for which you want to configure caching.
51-
1. On the top of the screen, select **Design** tab.
52-
1. In the **Inbound processing** section, select the **</>** icon.
53-
:::image type="content" source="media/api-management-howto-cache/code-editor.png" alt-text="Screenshot of the API Management policy editor in the portal.":::
51+
1. At the top of the screen, select the **Design** tab.
52+
1. In the **Inbound processing** section, select the **</>** icon:
53+
54+
:::image type="content" source="media/api-management-howto-cache/code-editor.png" alt-text="Screenshot that shows API Management APIs in the portal." lightbox="media/api-management-howto-cache/code-editor.png":::
5455

55-
8. In the `inbound` element, add the following policy:
56+
1. In the `inbound` element, add the following policy:
5657

5758
```xml
5859
<cache-lookup vary-by-developer="false" vary-by-developer-groups="false">
@@ -62,33 +63,35 @@ With caching policies shown in this example, the first request to a test operati
6263
</cache-lookup>
6364
```
6465

65-
9. In the `outbound` element, add the following policy:
66+
1. In the `outbound` element, add the following policy:
6667

6768
```xml
6869
<cache-store duration="20" />
6970
```
7071

71-
In this policy, **duration** specifies the expiration interval of the cached responses. In this example, the interval is **20** seconds.
72+
In this policy, `duration` specifies the expiration interval of the cached responses. The interval is 20 seconds.
7273

7374
> [!TIP]
74-
> If you are using an external cache, as described in [Use an external Azure Cache for Redis in Azure API Management](api-management-howto-cache-external.md), you may want to specify the `caching-type` attribute of the caching policies. See [API Management caching policies](api-management-policies.md#caching) for more details.
75+
> If you're using an external cache, as described in [Use an external Azure Cache for Redis in Azure API Management](api-management-howto-cache-external.md), you might want to specify the `caching-type` attribute of the caching policies. See [API Management caching policies](api-management-policies.md#caching) for more information.
7576
7677
## Call an operation and test the caching
77-
To see the caching in action, call an operation from the portal.
7878

79-
1. In the Azure portal, browse to your API Management instance.
80-
1. Select **APIs** > **APIs** from the menu on the left.
79+
To test caching, call an operation in the portal.
80+
81+
1. In the Azure portal, go to your API Management instance.
82+
1. Select **APIs** > **APIs** in the menu on the left.
8183
1. Select the API to which you added caching policies.
8284
1. Select an operation to test.
83-
1. Select the **Test** tab in the top right menu.
85+
1. Select the **Test** tab at the top of the window.
8486
1. Select **Trace** two or three times in quick succession.
8587
1. Under **HTTP response**, select the **Trace** tab.
86-
1. Jump to the **Inbound** section and scroll to the `cache-lookup` policy. You should see a message similar to the one in the following screenshot, indicating a cache hit:
88+
1. Go to the **Inbound** section and scroll to the `cache-lookup` policy. You should see a message similar to the one in the following screenshot, which indicates a cache hit:
8789
:::image type="content" source="media/api-management-howto-cache/test-api-cache-lookup.png" alt-text="Screenshot of cache-lookup when testing an API in the portal.":::
8890

8991
## Related content
92+
9093
* For more information about caching policies, see [Caching policies][Caching policies] in the [API Management policy reference][API Management policy reference].
91-
* For information on caching items by key using policy expressions, see [Custom caching in Azure API Management](api-management-sample-cache-by-key.md).
94+
* For information on caching items by key by using policy expressions, see [Custom caching in Azure API Management](api-management-sample-cache-by-key.md).
9295
* For more information about using external Azure Cache for Redis or Azure Managed Redis, see [Use an external Azure Cache for Redis in Azure API Management](api-management-howto-cache-external.md).
9396

9497
[api-management-management-console]: ./media/api-management-howto-cache/api-management-management-console.png

0 commit comments

Comments
 (0)