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.
This article mainly introduces how to set up the cache policy of IIS.
The following is the content related to setting IIS cache policy.
Install the IIS service
- Log on to your server.
- 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.
- 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.
- 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.
- 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.
- 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:
- 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.
- 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.
- Select a file to be cached in a specific format, right-click Properties, select HTTP Header, and then save the configuration.
- Taking the cache policy of the test.jpg file in the configuration
[$Path]/bindirectory 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.
- 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.
- Restart the IIS Admin Service service.
IIS cache volume settings
The following is the setting method of cache volume in IIS.
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.
- Click Start > Run, enter a services.msc, and click OK to go to the service page.
- Shut down the IIS Admin Service service.
- Open the
Windows\system32\inetsrv\MetaBase.xmlfile 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.
- Restart the IIS Admin Service service.