Disclaimer: This article may contain information about third-party products. Such information is for reference only. Alibaba Cloud does not make any guarantee, express or implied, with respect to the performance and reliability of third-party products, as well as potential impacts of operations on the products.

Overview

This article mainly introduces how to set up the cache policy of IIS.

Details

The following is the content related to setting IIS cache policy.

Install the IIS service

  1. Log on to your server.
  2. Click Start > Control Panel, set the viewing mode of the control panel to the small icon, click Default Programs > Programs and Features > Turn Windows Features on or off, select the Internet Information Services check box, and then click OK.
  3. Click Start > Run, enter a inetmgr, and click OK to enter the IIS Information Manager page.

IIS Expiration Time Policy Settings

Since the Alibaba Cloud Content Delivery Network only caches HTML, JPG, PNG, GIF and APK format files and does not cache documents in other formats, it is necessary to set the entire site to not cache before setting up files in specific formats. The following are the operation steps for setting IIS cache policy.

  1. Open IIS Information Manager, right-click Properties of the service website, select HTTP Header, select Enable Content Expiration, select Expiration Now, and then click OK.
  2. Expand the directory in the Website field, right-click the specified directory for which you want to set the cache time, click Properties > HTTP Header, select Expirate Time Period, set the expiration time value, and then click OK.
    Note: Files in HTML, JPG, PNG, GIF, and APK formats are placed separately in the specified directory, and there are no files in other formats in this directory, so cache policy can be set for this directory. If files in a specific format are not uniformly placed in the specified directory, but are placed in the same directory as Alibaba Cloud Content Delivery Network other format files that cannot be cached, the configuration process will become complicated.
  3. In order to avoid configuring files in a specific format one by one, IIS needs to support wildcard application. The wildcard configuration is as follows:
    1. Go to the IIS Information Manager page, right-click the Properties of the service website, select Home Directory, and then click Configure to go to the application configuration page. The application configuration page is as follows.
    2. In the Wildcard Application Mapping module, click Insert. If the displayed executable file is a file on the system disk, you do not need to select Confirm File Existence. Click OK. In the following dialog boxes, click OK. At this point, the IIS wildcard support settings are completed.
  4. Select a file to be cached in a specific format, right-click Properties, select HTTP Header, and then save the configuration.
  5. Taking the cache policy of the test.jpg file in the configuration [$Path]/bin directory as an example, use the "Notepad" program to open the IIS configuration file, locate the cache policy of "[$Path]/bin/test.jpg", and modify "test.jpg" to "*.jpg" to adopt this cache policy for all JPG format files in the specified directory.
    Hint:
    • In the IIS 6 environment, when modifying the IIS configuration file, turn off the IIS Admin Service service.
    • In IIS 7 and IIS 8 environments, when modifying IIS configuration files, please close the Windows Activation Service service.
    • [$Path] is the parent directory of the bin directory, subject to the actual situation on site.
  6. Restart the IIS Admin Service service.

IIS cache volume settings

The following is the setting method of cache volume in IIS.

Solution 1

Enter the IIS information manager page, select the specified site, double-click ASP > limit attribute, and set the maximum request entity topic limit to the specified size.

Note: The default value of the maximum request entity body limit is 200000, that is, about 200KB, which can be set to 52000000, that is, 50MB.

Solution 2

  1. Click Start > Run, enter a services.msc, and click OK to go to the service page.
  2. Shut down the IIS Admin Service service.
  3. Open the Windows\system32\inetsrv\MetaBase.xml file in the system disk and set the AspMaxRequestEntityAllowed parameter values.
    Note: The default value of the AspMaxRequestEntityAllowed is 204800, that is, 200KB, which can be set to 512000000, that is, 500MB.
  4. Restart the IIS Admin Service service.

Application scope

  • CDN