All Products
Search
Document Center

:Configure an IIS cache policy

Last Updated:Feb 28, 2024

When you configure an Internet Information Services (IIS) cache policy, you need to configure output caching, HTTP headers, and other related properties. This topic describes how to configure an IIS cache policy.

Note

Disclaimer: This topic may contain information about third-party products. The information is only for reference. Alibaba Cloud does not make guarantees or other forms of commitments for the performance and reliability of the third-party tools, or the potential impacts of operations performed by using these tools.

Install IIS

  1. Log on to the server.

  2. Choose Start > Control Panel, set View By to Small icons, choose > Programs and Features > Turn Windows features on or off, select Internet Information Services, and then click OK.

Configure a cache expiration policy in IIS

  1. Disable caching globally.

    1. Choose Start > Run, enter inetmgr, and then click OK.

    2. Right-click the website and select Properties. Click HTTP Headers, select Enable content expiration, select Expire immediately, and then click OK.

  2. Specify a TTL value for a specific file format.

    1. Expand the Sites directory, right-click the website for which you want to specify a TTL value, select Properties > HTTP Headers.

    2. Select Expire after, specify a TTL, and then click OK.

  3. Support wildcard applications (batch configuration).

    1. On the IIS Manager panel, right-click the website, and select Properties. Click the Home Directory tab, and then click Configuration....

    2. In the Wildcard application maps section, click Insert... to insert a new mapping. Confirm the settings, and then save the mapping.

    3. Right-click the format that you want to cache, such as *.jpg, select Properties, and then click the HTTP Headers tab. Configure HTTP headers and save the settings.

  4. Modify the configuration file to implement wildcard rules.

    In this example, the cache policy of the test.jpg file in the [$Path]/bin directory is configured. Use Notepad to open the IIS configuration file, find the cache policy of the [$Path]/bin/test.jpg file, and modify "test.jpg" to "*.jpg". This way, the cache policy takes effect for all .jpg files in the directory.

    Note
    • In IIS 6, disable IIS Admin Service before you modify the IIS configuration file.

    • In IIS 7 or IIS 8, disable Windows Activation Service before you modify the IIS configuration file.

    • [$Path] is the parent directory of the bin directory. The actual directory shall prevail.

  5. Restarts a service.

    Restart IIS Admin Service or Windows Activation Service based on the IIS version for the changes to take effect.

You can perform the preceding steps to configure different cache policies for different types of resources or specific directories based on your business requirements.

Configure the IIS cache size

You can use one of the following methods to configure the IIS cache size:

Method 1

On the IIS Manager panel, select the specified site, double-click ASP, expand Limits Properties, and then set Maximum Request Entity Subject Limit to a specific size.

Note

The default value of Maximum Request Entity Subject Limit is 200,000, which is approximately 200 KB. The maximum value is 52,000,000, which is approximately 50 MB.

Method 2

  1. Choose Start > Run, enter services.msc, and then click OK.

  2. Disable IIS Admin Service.

  3. Open the Windows\system32\inetsrv\MetaBase.xml file in the system disk and configure the AspMaxRequestEntityAllowed parameter.

    Note

    The default value of the AspMaxRequestEntityAllowed parameter is 204,800, which is 200 KB. The maximum value is 512,000,000, which is 500 MB.

  4. Restart IIS Admin Service.