Optimize your Internet Information Services (IIS) configuration to address slow website load times and prevent file upload failures. Setting a cache policy can improve website response speed, while adjusting the maximum request size limit for ASP applications (AspMaxRequestEntityAllowed) enables large file uploads.
Use cases
Improve performance: Set a long-term cache policy for static resources that are infrequently updated, such as images, CSS, and JavaScript files. This reduces server requests and speeds up page load times.
Support large file uploads: Adjust the request size limit for ASP applications to meet business needs, such as uploading videos or large documents.
Scope
Third-party product responsibility: Alibaba Cloud provides no warranties for the performance, reliability, or operation of third-party products, such as IIS, mentioned in this document.
Version compatibility: The steps in this document are primarily based on IIS 6.0. In IIS 7.0 and later versions, some UI elements, service names (such as
Windows Activation Service), and the configuration file (MetaBase.xml) may differ. Adjust the steps for your specific environment.ASP request limit: The "Maximum Requesting Entity Body Limit" setting affects only ASP applications and does not apply to other types of web applications.
Install the IIS service for Windows (optional)
On the server desktop, click Start > Control Panel.
Set View by to Small icons, and then click Default Programs > Programs And Features.
In the navigation pane on the left, click Turn Windows Features On Or Off.
In the Windows Features dialog box, select Internet Information Services.
Click OK and wait for the installation to complete.
Configure the content cache policy
Purpose: Configure HTTP Response Headers to instruct browsers or proxy servers to use their local cache for a specified period without re-requesting it from the server.
Disable caching globally (for dynamic content)
This method disables caching for all website content by default. This ensures users receive the latest data on every visit, making it ideal for dynamic sites with frequently changing content.
Open IIS Manager by entering
inetmgrin the Run dialog box.In the Connections pane on the left, right-click the target site and select Properties.
In the Properties dialog box, click the HTTP Headers tab.
Select Enable Content Expiration and then select Expire Immediately.
Click OK to save.
Set caching for specific directories or files (for static resources)
This method sets a long cache duration for directories that contain static resources like images, CSS, and JS files. It can significantly improve load speed.
In IIS Manager, expand the directory tree of the target site.
Right-click the specific directory or file for which you want to set caching, such as the
imagesdirectory, and select Properties.Click the HTTP Headers tab and select Enable Content Expiration.
Select Expire After and set a long cache duration, such as 30 days.
Click OK.
Use a wildcard to set cache policies in bulk (advanced)
This method is useful for applying a uniform cache policy to files of the same type that are located in different directories, such as all .jpg files.
IIS 6.0: Modifying the MetaBase.xml file directly to implement this feature is not recommended. The operation is complex and high-risk.
IIS 7.0 and later (Recommended): Use the
web.configfile for configuration. The<location>and<staticContent>elements let you set a cache policy for specific file types, providing a safer and more flexible method.
Adjust the ASP maximum requesting entity body limit
Purpose: This setting limits the maximum amount of data a client can send to an ASP page using the POST method. Its default value of approximately 200 KB can cause large file uploads to fail.
Configure using the IIS Manager interface (recommended)
In IIS Manager, select the target site.
In Features View, double-click the ASP feature icon.
On the ASP configuration page, expand Limits Properties.
Modify the value of Maximum Requesting Entity Body Limit (in bytes).
Default value:
200,000(about 200 KB)Example: To support 50 MB file uploads, set the value to
52,428,800.
In the Actions pane on the right, click Apply to save the changes.
Modify the configuration file directly
Stop the IIS Admin Service.
Back up the
C:\Windows\System32\inetsrv\MetaBase.xmlfile and then open it with a text editor.In the file, search for the
AspMaxRequestEntityAllowedparameter and modify its value.Default value:
204800(200 KB)Example: To support 500 MB file uploads, set the value to
524,288,000.
Save and close the
MetaBase.xmlfile.
Restart the service to apply the configuration
After you change the configuration, you must restart the corresponding IIS service for the changes to take effect.
IIS 6.0: In the Services manager, restart the IIS Admin Service.
IIS 7.0/8.0: In the Services manager, restart the Windows Activation Service.
Verify the cache policy
Open the Network panel in your browser's developer tools (keyboard shortcut: F12).
Visit the website and select a resource for which you have configured caching, such as an image.
In the Headers section, check the Response Headers.
Successful configuration: The response headers should contain a
Cache-Control: max-age=[seconds]orExpires: [future date]field.Immediate expiration: The response headers should contain
Cache-Control: no-cacheor anExpiresfield with a value that is a past date.
FAQ
Why are my configuration changes not taking effect?
This issue typically occurs for one of the following reasons. Check them in order:
Incorrect Service Restarted: The changes will not apply until the correct service is restarted.
For IIS 6.0: Restart the
IIS Admin Service.For IIS 7.0/8.0: Restart the
Windows Activation Service.
Configuration Override: A more specific configuration is overriding your global settings. For example, a cache policy set on a specific directory will always take precedence over the site-wide policy.
Browser Cache During Verification: Your browser may be serving a stale response from its local cache. To get a fresh response directly from the server, clear your browser cache or enable the "Disable cache" option in your browser's developer tools while testing.
Why do file uploads still fail after I adjusted the request size limit?
This usually happens because your web application has its own upload size limit that is separate from the IIS server-level setting. The AspMaxRequestEntityAllowed setting in IIS only controls the maximum request body size that the web server will accept. The application running on the server (e.g., an ASP.NET application) often enforces its own, lower limit. For example, an ASP.NET application's web.config file may contain an <httpRuntime> setting that also needs to be modified.