Skip to content

Commit bdb0b4a

Browse files
author
dksimpson
committedFeb 15, 2018
task 917: Add caching rules example and add screenshots
1 parent 5dd745a commit bdb0b4a

File tree

5 files changed

+57
-9
lines changed

5 files changed

+57
-9
lines changed
 

‎articles/cdn/cdn-manage-expiration-of-cloud-service-content.md

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ title: Manage expiration of web content in Azure Content Delivery Network | Micr
33
description: Learn how to manage expiration of Azure Web Apps/Cloud Services, ASP.NET, or IIS content in Azure CDN.
44
services: cdn
55
documentationcenter: .NET
6-
author: zhangmanling
7-
manager: erikre
6+
author: dksimpson
7+
manager: akucer
88
editor: ''
99

1010
ms.assetid: bef53fcc-bb13-4002-9324-9edee9da8288
@@ -13,7 +13,7 @@ ms.workload: media
1313
ms.tgt_pltfrm: na
1414
ms.devlang: dotnet
1515
ms.topic: article
16-
ms.date: 11/10/2017
16+
ms.date: 02/15/2018
1717
ms.author: mazha
1818

1919
---
@@ -23,26 +23,74 @@ ms.author: mazha
2323
> * [Azure Blob storage](cdn-manage-expiration-of-blob-content.md)
2424
>
2525
26-
The files from any publicly accessible origin web server can be cached in Azure Content Delivery Network (CDN) until their time-to-live (TTL) elapses. The TTL is determined by the `Cache-Control` header in the HTTP response from the origin server. This article describes how to set `Cache-Control` headers for the Web Apps feature of Microsoft Azure App Service, Azure Cloud Services, ASP.NET applications, and Internet Information Services (IIS) sites, all of which are configured similarly. You can set the `Cache-Control` header either by using configuration files or programmatically.
26+
Files from publicly accessible origin web servers can be cached in Azure Content Delivery Network (CDN) until their time-to-live (TTL) elapses. The TTL is determined by the `Cache-Control` header in the HTTP response from the origin server. This article describes how to set `Cache-Control` headers for the Web Apps feature of Microsoft Azure App Service, Azure Cloud Services, ASP.NET applications, and Internet Information Services (IIS) sites, all of which are configured similarly. You can set the `Cache-Control` header either by using configuration files or programmatically.
2727

28-
You can also control cache settings from the Azure portal by setting [CDN caching rules](cdn-caching-rules.md). If you set up one or more caching rules and set their caching behavior to **Override** or **Bypass cache**, the origin-provided caching settings discussed in this article are ignored. For information about general caching concepts, see [How caching works](cdn-how-caching-works.md).
28+
You can also control cache settings from the Azure portal by setting [CDN caching rules](cdn-caching-rules.md). If you create one or more caching rules and set their caching behavior to **Override** or **Bypass cache**, the origin-provided caching settings discussed in this article are ignored. For information about general caching concepts, see [How caching works](cdn-how-caching-works.md).
2929

3030
> [!TIP]
31-
> You can choose to set no TTL on a file. In this case, Azure CDN automatically applies a default TTL of seven days, unless you have set up caching rules in the Azure portal. This default TTL applies only to general web delivery optimizations. For large file optimizations, the default TTL is one day, and for media streaming optimizations, the default TTL is one year.
31+
> You can choose to set no TTL on a file. In this case, Azure CDN automatically applies a default TTL of seven days, unless you've set up caching rules in the Azure portal. This default TTL applies only to general web delivery optimizations. For large file optimizations, the default TTL is one day, and for media streaming optimizations, the default TTL is one year.
3232
>
3333
> For more information about how Azure CDN works to speed up access to files and other resources, see [Overview of the Azure Content Delivery Network](cdn-overview.md).
3434
>
3535
36+
## Setting Cache-Control headers by using CDN caching rules
37+
The preferred method for setting a web server's `Cache-Control` header is to use caching rules in the Azure portal. For more information about CDN caching rules, see [Control Azure CDN caching behavior with caching rules](cdn-caching-rules.md).
38+
39+
> [!NOTE]
40+
> Caching rules are available only for **Azure CDN from Verizon Standard** and **Azure CDN from Akamai Standard** profiles. For **Azure CDN from Verizon Premium** profiles, you must use the [Azure CDN rules engine](cdn-rules-engine.md) in the **Manage** portal for similar functionality.
41+
42+
**To navigate to the CDN caching rules page**:
43+
44+
1. In the Azure portal, select a CDN profile, then select the endpoint for the web server.
45+
46+
2. In the left pane under Settings, select **Caching rules**.
47+
48+
![CDN caching rules button](./media/cdn-manage-expiration-of-cloud-service-content/cdn-caching-rules-btn.png)
49+
50+
The **Caching rules** page appears.
51+
52+
![CDN caching page](./media/cdn-manage-expiration-of-cloud-service-content/cdn-caching-page.png)
53+
54+
55+
**To set a web server's Cache-Control headers by using global caching rules:**
56+
57+
1. Under **Global caching rules**, set **Query string caching behavior** to **Ignore query strings** and set **Caching behavior** to **Override**.
58+
59+
2. For **Cache expiration duration**, enter 3600 in the **Seconds** box or 1 in the **Hours** box.
60+
61+
![CDN global caching rules example](./media/cdn-manage-expiration-of-cloud-service-content/cdn-global-caching-rules-example.png)
62+
63+
This global caching rule sets a cache duration of one hour and affects all requests to the endpoint. It overrides any `Cache-Control` or `Expires` HTTP headers that are sent by the origin server specified by the endpoint.
64+
65+
3. Select **Save**.
66+
67+
**To set a web server file's Cache-Control headers by using custom caching rules:**
68+
69+
1. Under **Custom caching rules**, create two match conditions:
70+
71+
a. For the first match condition, set **Match condition** to **Path** and enter `/webfolder1/*` for **Match value**. Set **Caching behavior** to **Override** and enter 4 in the **Hours** box.
72+
73+
b. For the second match condition, set **Match condition** to **Path** and enter `/webfolder1/file1.txt` for **Match value**. Set **Caching behavior** to **Override** and enter 2 in the **Hours** box.
74+
75+
![CDN custom caching rules example](./media/cdn-manage-expiration-of-cloud-service-content/cdn-custom-caching-rules-example.png)
76+
77+
The first custom caching rule sets a cache duration of four hours for any files in the `/webfolder1` folder on the origin server specified by your endpoint. The second rule overrides the first rule for the `file1.txt` file only and sets a cache duration of two hours for it.
78+
79+
2. Select **Save**.
80+
81+
3682
## Setting Cache-Control headers by using configuration files
37-
For static content, such as images and style sheets, you can control the update frequency by modifying the **applicationHost.config** or **Web.config** configuration files for your web application. The `<system.webServer>/<staticContent>/<clientCache>` element in either file sets the `Cache-Control` header for your content.
83+
For static content, such as images and style sheets, you can control the update frequency by modifying the **applicationHost.config** or **Web.config** configuration files for your web application. To set the `Cache-Control` header for your content, use the `<system.webServer>/<staticContent>/<clientCache>` element in either file.
3884

3985
### Using ApplicationHost.config files
4086
The **ApplicationHost.config** file is the root file of the IIS configuration system. The configuration settings in an **ApplicationHost.config** file affect all applications on the site, but are overridden by the settings of any **Web.config** files that exist for a web application.
4187

4288
### Using Web.config files
43-
With a **Web.config** file, you can customize the way your entire web application or a specific directory on your web application behaves. Typically, you have at least one **Web.config** file in the root folder of your web application. For each **Web.config** file in a specific folder, the configuration settings affect everything in that folder and all its subfolders, unless they are overridden at the subfolder level by another **Web.config** file. For example, you can set a `<clientCache>` element in a **Web.config** file in the root folder of your web application to cache all static content on your web application for three days. You can also add a **Web.config** file in a subfolder with more variable content (for example, `\frequent`) and set its `<clientCache>` element to cache the subfolder's content for six hours. The net result is that content on the entire web site will be cached for three days, except for any content in the `\frequent` directory, which will be cached for only six hours.
89+
With a **Web.config** file, you can customize the way your entire web application or a specific directory on your web application behaves. Typically, you have at least one **Web.config** file in the root folder of your web application. For each **Web.config** file in a specific folder, the configuration settings affect everything in that folder and its subfolders, unless they are overridden at the subfolder level by another **Web.config** file.
90+
91+
For example, you can set a `<clientCache>` element in a **Web.config** file in the root folder of your web application to cache all static content on your web application for three days. You can also add a **Web.config** file in a subfolder with more variable content (for example, `\frequent`) and set its `<clientCache>` element to cache the subfolder's content for six hours. The net result is that content on the entire web site is cached for three days, except for any content in the `\frequent` directory, which is cached for only six hours.
4492

45-
The following XML example shows how to set the `<clientCache>` element in a configuration file to specify a maximum age of three days:
93+
The following XML configuration file example shows how to set the `<clientCache>` element to specify a maximum age of three days:
4694

4795
```xml
4896
<configuration>
Loading
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.