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.
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
Log on to the server.
Choose
, set View By to Small icons, choose , select Internet Information Services, and then click OK.
Configure a cache expiration policy in IIS
Disable caching globally.
Choose
, enter inetmgr, and then click OK.Right-click the website and select Properties. Click HTTP Headers, select Enable content expiration, select Expire immediately, and then click OK.
Specify a TTL value for a specific file format.
Expand the Sites directory, right-click the website for which you want to specify a TTL value, select
.Select Expire after, specify a TTL, and then click OK.
Support wildcard applications (batch configuration).
On the IIS Manager panel, right-click the website, and select Properties. Click the Home Directory tab, and then click Configuration....
In the Wildcard application maps section, click Insert... to insert a new mapping. Confirm the settings, and then save the mapping.
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.
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.NoteIn 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.
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.
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
Choose
, enter services.msc, and then click OK.Disable IIS Admin Service.
Open the
Windows\system32\inetsrv\MetaBase.xml
file in the system disk and configure the AspMaxRequestEntityAllowed parameter.NoteThe default value of the AspMaxRequestEntityAllowed parameter is 204,800, which is 200 KB. The maximum value is 512,000,000, which is 500 MB.
Restart IIS Admin Service.