|
1 | 1 | ---
|
2 |
| -title: Add caching to improve performance in Azure API Management | Microsoft Docs |
| 2 | +title: Add caching to improve performance in Azure API Management |
3 | 3 | description: Learn how to improve the latency, bandwidth consumption, and web service load for API Management service calls.
|
4 | 4 | author: dlepow
|
5 |
| -manager: erikre |
6 |
| -ms.assetid: 740f6a27-8323-474d-ade2-828ae0c75e7a |
7 | 5 | ms.service: azure-api-management
|
8 | 6 | ms.topic: conceptual
|
9 | 7 | ms.date: 03/20/2024
|
@@ -44,48 +42,46 @@ To complete this tutorial:
|
44 | 42 |
|
45 | 43 | ## <a name="caching-policies"> </a>Add the caching policies
|
46 | 44 |
|
47 |
| -With caching policies shown in this example, the first request to the **GetSpeakers** 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 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. |
48 | 46 |
|
49 | 47 | 1. Sign in to the [Azure portal](https://portal.azure.com).
|
50 |
| -2. Browse to your APIM instance. |
51 |
| -3. Select the **API** tab. |
52 |
| -4. Click **Demo Conference API** from your API list. |
53 |
| -5. Select **GetSpeakers**. |
54 |
| -6. On the top of the screen, select **Design** tab. |
55 |
| -7. In the **Inbound processing** section, click the **</>** icon. |
| 48 | +1. Browse to your API Management instance. |
| 49 | +1. Select **APIs** > **APIs** from the menu on the left. |
| 50 | +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."::: |
56 | 54 |
|
57 |
| -  |
| 55 | +8. In the **Inbound** element, add the following policy: |
58 | 56 |
|
59 |
| -8. In the **inbound** element, add the following policy: |
60 |
| - |
61 |
| - ``` |
| 57 | + ```xml |
62 | 58 | <cache-lookup vary-by-developer="false" vary-by-developer-groups="false">
|
63 | 59 | <vary-by-header>Accept</vary-by-header>
|
64 | 60 | <vary-by-header>Accept-Charset</vary-by-header>
|
65 | 61 | <vary-by-header>Authorization</vary-by-header>
|
66 | 62 | </cache-lookup>
|
67 | 63 | ```
|
68 | 64 |
|
69 |
| -9. In the **outbound** element, add the following policy: |
| 65 | +9. In the **Outbound** element, add the following policy: |
70 | 66 |
|
71 |
| - ``` |
| 67 | + ```xml |
72 | 68 | <cache-store duration="20" />
|
73 | 69 | ```
|
74 | 70 |
|
75 |
| - **Duration** specifies the expiration interval of the cached responses. In this example, the interval is **20** seconds. |
| 71 | + In this policy, **duration** specifies the expiration interval of the cached responses. In this example, the interval is **20** seconds. |
76 | 72 |
|
77 | 73 | > [!TIP]
|
78 | 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.
|
79 | 75 |
|
80 | 76 | ## <a name="test-operation"> </a>Call an operation and test the caching
|
81 |
| -To see the caching in action, call the operation from the developer portal. |
82 |
| - |
83 |
| -1. In the Azure portal, browse to your APIM instance. |
84 |
| -2. Select the **APIs** tab. |
85 |
| -3. Select the API to which you added caching policies. |
86 |
| -4. Select the **GetSpeakers** operation. |
87 |
| -5. Click the **Test** tab in the top right menu. |
88 |
| -6. Press **Send**. |
| 77 | +To see the caching in action, call an operation from the portal. |
| 78 | + |
| 79 | +1. In the Azure portal, browse to your API Management instance. |
| 80 | +1. Select **APIs** > **APIs** from the menu on the left. |
| 81 | +1. Select the API to which you added caching policies. |
| 82 | +1. Select an operation to test. |
| 83 | +1. Select the **Test** tab in the top right menu. |
| 84 | +1. Select **Send**. |
89 | 85 |
|
90 | 86 | ## <a name="next-steps"> </a>Next steps
|
91 | 87 | * For more information about caching policies, see [Caching policies][Caching policies] in the [API Management policy reference][API Management policy reference].
|
|
0 commit comments