You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cdn/cdn-caching-rules.md
+18-22Lines changed: 18 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,37 +2,33 @@
2
2
title: Control Azure CDN caching behavior with caching rules | Microsoft Docs
3
3
description: You can use CDN caching rules to set or modify default cache expiration behavior both globally and with conditions, such as a URL path and file extensions.
4
4
services: cdn
5
-
documentationcenter: ''
6
5
author: duongau
7
-
manager: danielgi
8
-
editor: ''
9
-
6
+
manager: kumud
10
7
ms.service: azure-cdn
11
-
ms.workload: tbd
12
-
ms.tgt_pltfrm: na
13
8
ms.topic: how-to
14
-
ms.date: 03/19/2019
9
+
ms.date: 02/21/2023
15
10
ms.author: duau
16
11
---
17
12
18
13
# Control Azure CDN caching behavior with caching rules
19
14
15
+
This article describes how you can use content delivery network (CDN) caching rules to set or modify default cache expiration behavior. These caching rules can either be global or with custom conditions, such as a URL path and file extension.
16
+
20
17
> [!NOTE]
21
18
> Caching rules are available only for **Azure CDN Standard from Verizon** and **Azure CDN Standard from Akamai** profiles. For **Azure CDN from Microsoft** profiles, you must use the [Standard rules engine](cdn-standard-rules-engine-reference.md) For **Azure CDN Premium from Verizon** profiles, you must use the [Verizon Premium rules engine](./cdn-verizon-premium-rules-engine.md) in the **Manage** portal for similar functionality.
22
19
23
-
Azure Content Delivery Network (CDN) offers two ways to control how your files are cached:
20
+
Azure Content Delivery Network (CDN) offers two ways to control how your files get cached:
24
21
25
-
-Caching rules: This article describes how you can use content delivery network (CDN) caching rules to set or modify default cache expiration behavior both globally and with custom conditions, such as a URL path and file extension. Azure CDN provides two types of caching rules:
22
+
**Caching rules:**Azure CDN provides two types of caching rules: global and custom.
26
23
27
-
- Global caching rules: You can set one global caching rule for each endpoint in your profile, which affects all requests to the endpoint. The global caching rule overrides any HTTP cache-directive headers, if set.
24
+
- Global caching rules - You can set one global caching rule for each endpoint in your profile, which affects all requests to the endpoint. The global caching rule overrides any HTTP cache-directive headers, if set.
28
25
29
-
- Custom caching rules: You can set one or more custom caching rules for each endpoint in your profile. Custom caching rules match specific paths and file extensions, are processed in order, and override the global caching rule, if set.
26
+
- Custom caching rules - You can set one or more custom caching rules for each endpoint in your profile. Custom caching rules match specific paths and file extensions, get processed in order, and override the global caching rule, if set.
30
27
31
-
-Query string caching: You can adjust how the Azure CDN treats caching for requests with query strings. For information, see [Control Azure CDN caching behavior with query strings](cdn-query-string.md). If the file is not cacheable, the query string caching setting has no effect, based on caching rules and CDN default behaviors.
28
+
**Query string caching:** You can adjust how the Azure CDN treats caching for requests with query strings. For information, see [Control Azure CDN caching behavior with query strings](cdn-query-string.md). If the file isn't cacheable, the query string caching setting has no effect, based on caching rules and CDN default behaviors.
32
29
33
30
For information about default caching behavior and caching directive headers, see [How caching works](cdn-how-caching-works.md).
34
31
35
-
36
32
## Accessing Azure CDN caching rules
37
33
38
34
1. Open the Azure portal, select a CDN profile, then select an endpoint.
@@ -49,9 +45,9 @@ For information about default caching behavior and caching directive headers, se
49
45
## Caching behavior settings
50
46
For global and custom caching rules, you can specify the following **Caching behavior** settings:
51
47
52
-
-**Bypass cache**: Do not cache and ignore origin-provided cache-directive headers.
48
+
-**Bypass cache**: Don't cache and ignore origin-provided cache-directive headers.
53
49
54
-
-**Override**: Ignore origin-provided cache duration; use the provided cache duration instead. This will not override cache-control: no-cache.
50
+
-**Override**: Ignore origin-provided cache duration; use the provided cache duration instead. This setting doesn't override cache-control: no-cache.
55
51
56
52
> [!NOTE]
57
53
> For **Azure CDN from Microsoft** profiles, cache expiration override is only applicable to status codes 200 and 206.
@@ -69,7 +65,7 @@ For global and custom caching rules, you can specify the cache expiration durati
69
65
70
66
- For the **Override** and **Set if missing****Caching behavior** settings, valid cache durations range between 0 seconds and 366 days. For a value of 0 seconds, the CDN caches the content, but must revalidate each request with the origin server.
71
67
72
-
- For the **Bypass cache** setting, the cache duration is automatically set to 0 seconds and cannot be changed.
68
+
- For the **Bypass cache** setting, the cache duration gets automatically set to 0 seconds, which isn't a modifiable value.
73
69
74
70
## Custom caching rules match conditions
75
71
@@ -80,30 +76,30 @@ For custom cache rules, two match conditions are available:
80
76
-**Extension**: This condition matches the file extension of the requested file. You can provide a list of comma-separated file extensions to match. For example, _.jpg_, _.mp3_, or _.png_. The maximum number of extensions is 50 and the maximum number of characters per extension is 16.
81
77
82
78
## Global and custom rule processing order
83
-
Global and custom caching rules are processed in the following order:
79
+
Global and custom caching rules get processed in the following order:
84
80
85
81
- Global caching rules take precedence over the default CDN caching behavior (HTTP cache-directive header settings).
86
82
87
-
- Custom caching rules take precedence over global caching rules, where they apply. Custom caching rules are processed in order from top to bottom. That is, if a request matches both conditions, rules at the bottom of the list take precedence over rules at the top of the list. Therefore, you should place more specific rules lower in the list.
83
+
- Custom caching rules take precedence over global caching rules, where they apply. Custom caching rules get processed in order from top to bottom. That is, if a request matches both conditions, rules at the bottom of the list take precedence over rules at the top of the list. Therefore, you should place more specific rules lower in the list.
88
84
89
85
**Example**:
90
86
- Global caching rule:
91
87
- Caching behavior: **Override**
92
-
- Cache expiration duration: 1 day
88
+
- Cache expiration duration: One day
93
89
94
90
- Custom caching rule #1:
95
91
- Match condition: **Path**
96
92
- Match value: _/home/*_
97
93
- Caching behavior: **Override**
98
-
- Cache expiration duration: 2 days
94
+
- Cache expiration duration: Two days
99
95
100
96
- Custom caching rule #2:
101
97
- Match condition: **Extension**
102
98
- Match value: _.html_
103
99
- Caching behavior: **Set if missing**
104
-
- Cache expiration duration: 3 days
100
+
- Cache expiration duration: Three days
105
101
106
-
When these rules are set, a request for _<endpoint hostname>_.azureedge.net/home/index.html triggers custom caching rule #2, which is set to: **Set if missing** and 3 days. Therefore, if the *index.html* file has `Cache-Control` or `Expires` HTTP headers, they are honored; otherwise, if these headers are not set, the file is cached for 3 days.
102
+
When you set these rules, a request for _<endpoint hostname>_.azureedge.net/home/index.html triggers custom caching rule #2, which get set to: **Set if missing** and 3 days. Therefore, if the *index.html* file has `Cache-Control` or `Expires` HTTP headers, they get honored; otherwise, if you don't set these headers, the file gets cached for three days.
107
103
108
104
> [!NOTE]
109
105
> Files that are cached before a rule change maintain their origin cache duration setting. To reset their cache durations, you must [purge the file](cdn-purge-endpoint.md).
0 commit comments