Configure cache policies in Internet Information Services (IIS) by setting the output cache, HTTP headers, and related properties.
Disclaimer: This document may contain information about third-party products for reference purposes only. Alibaba Cloud does not provide any express or implied warranties regarding the performance or reliability of third-party products, nor does it assume any liability for potential issues that may arise from their use.
Install IIS
Log on to the server.
Navigate to . Set the view mode to Small icons, and then click . Select Internet Information Services and click OK.
Configure the IIS cache expiration policy
-
Disable caching globally.
Click , enter inetmgr, and then click OK to open IIS Manager.
-
Right-click the site and select Properties. Click the HTTP Headers tab, select Enable content expiration, select Expire immediately, and then click OK.
-
Set the cache duration for specific file formats.
Expand the site, right-click the target directory, and select .
-
Select Expire after, set a cache duration, and click OK.
-
Enable wildcard application mapping for batch configuration.
-
In IIS Manager, right-click the site, select Properties, click the Home Directory tab, and then click Configuration to open the Application Configuration page.
In the Wildcard application maps section, click Insert to add a new mapping, then save your settings.
To configure caching for a specific file type, such as
*.jpg, right-click a file of that type, select Properties, and go to the HTTP Headers tab. Configure the settings and save your changes.
-
-
Apply wildcard rules by editing the configuration file.
To apply a cache policy to all JPG files in the
[$Path]/bindirectory, open the IIS configuration file in a text editor. Locate the cache policy entry for[$Path]/bin/test.jpgand replacetest.jpgwith*.jpg.NoteIn an IIS 6 environment, stop the IIS Admin Service before modifying the IIS configuration file.
In IIS 7 and IIS 8 environments, stop the Windows Process Activation Service before modifying the IIS configuration file.
[$Path]represents the parent directory of the bin directory. The actual path varies by environment.
-
Restart the service.
Restart the IIS Admin Service (IIS 6) or the Windows Process Activation Service (IIS 7 and IIS 8) to apply the changes.
Configure the IIS cache size
Use one of the following methods to configure the IIS cache size.
Method 1: use IIS Manager
In IIS Manager, select the target site and double-click ASP. In the Limits Properties section, set Maximum Requesting Entity Body Limit to the desired size.
The default is 200,000 bytes (approximately 200 KB). You can increase this value, for example, to 52,000,000 bytes (approximately 50 MB).
Method 2: edit MetaBase.xml
Click , enter services.msc, and then click OK to open the Services console.
Stop the IIS Admin Service.
-
Open
Windows\system32\inetsrv\MetaBase.xmlon the system drive and set the value of theAspMaxRequestEntityAllowedparameter.NoteThe default value of
AspMaxRequestEntityAllowedis 204,800 bytes (200 KB). You can increase this value, for example, to 512,000,000 bytes (approximately 500 MB). Restart the IIS Admin Service.