The
<httpCompression>
element specifies the HTTP compression settings for Internet Information Services (IIS) 7. HTTP compression can provide faster transmission times between IIS and client browsers that can accept compressed files.Note: An HTTP client must initiate communication for compressed content by sending the appropriate HTTP Accept-encoding header. If a client is not capable of HTTP compression, it will not pass that header and IIS 7 will always return uncompressed content.
There are two different types of compression that IIS 7 uses:
- Static Compression:IIS 7 caches compressed static content in the path that is specified by the directory attribute, which increases compression performance by eliminating the need to recompress content that has already been compressed. After IIS 7 has compressed a file, subsequent requests are given the compressed copy of the file from the cache directory.
The staticCompressionEnableCpuUsage andstaticCompressionDisableCpuUsage attributes specify when IIS 7 will compress static files based on CPU usage.
You should use static compression with files that do not typically change, such as HTML files (*.html, *.htm), text files (*.txt), Microsoft Office documents (*.doc, *.xls, *.ppt), etc. The size of these files can be reduced through compression, which reduces download times for client requests and reduces bandwidth on the server.
Note: Image files such as *.png and *.png files are also static files, but typically they do not benefit from HTTP compression because these image files are already compressed. - Dynamic Compression:Unlike static compression, IIS 7 performs dynamic compression each time a client requests the content, but the compressed version is not cached to disk. This change is made because of the primary difference between static and dynamic content. Static content does not change. However, dynamic content is typically content that is created by an application and therefore changes often, such as Active Server Pages (ASP) or ASP.NET content. Since dynamic content should change often, IIS 7 does not cache it.
The dynamicCompressionEnableCpuUsage anddynamicCompressionDisableCpuUsage attributes specify when IIS 7 will compress dynamic files based on CPU usage.
Compatibility
Version Notes IIS 7.5 In IIS 7.5, the default value for the minFileSizeForComp
attribute has been changed, and thedynamicCompressionBufferLimit
attribute was added.IIS 7.0 The <httpCompression>
element was introduced in IIS 7.0.IIS 6.0 The <httpCompression>
element replaces the following IIS 6.0 metabase properties:- HcCacheControlHeader
- HcCompressionDirectory
- HcDoDiskSpaceLimiting
- HcExpiresHeader
- HcMaxDiskSpaceUsage
- HcMinFileSizeForComp
- HcNoCompressionForHttp10
- HcNoCompressionForProxies
- HcNoCompressionForRange
- HcSendCacheHeaders
Setup
HTTP compression is usually available on the default installation of IIS 7. However, only static compression is installed by default. To install static or dynamic compression, use the following steps.
Windows Server 2008 or Windows Server 2008 R2
- On the taskbar, click Start, point to Administrative Tools, and then click Server Manager.
- In the Server Manager hierarchy pane, expand Roles, and then click Web Server (IIS).
- In the Web Server (IIS) pane, scroll to the Role Services section, and then click Add Role Services.
- On the Select Role Services page of the Add Role Services Wizard, select Dynamic Content Compression if you want to install dynamic compression and Static Content Compression if you want to install static compression, and then click Next.
- On the Confirm Installation Selections page, click Install.
- On the Results page, click Close.
Windows Vista or Windows 7
- On the taskbar, click Start, and then click Control Panel.
- In Control Panel, click Programs and Features, and then clickTurn Windows Features on or off.
- Expand Internet Information Services, then World Wide Web Services, then Performance Features.
- Select Http Compression Dynamic if you want to install dynamic compression and Static Content Compression if you want to install static compression.
- Click OK.
How To
How to enable or disable static and dynamic compression for a site or application
- Open Internet Information Services (IIS) Manager:
- If you are using Windows Server 2008 or Windows Server 2008 R2:
- On the taskbar, click Start, point to Administrative Tools, and then click Internet Information Services (IIS) Manager.
- If you are using Windows Vista or Windows 7:
- On the taskbar, click Start, and then click Control Panel.
- Double-click Administrative Tools, and then double-clickInternet Information Services (IIS) Manager.
- If you are using Windows Server 2008 or Windows Server 2008 R2:
- In the Connections pane, go to the connection, site, application, or directory for which you want to enable compression.
- In the Home pane, double-click Compression.
- In the Compression pane, check the boxes to enable static or dynamic compression, or remove the check marks to disable static or dynamic compression.
- Once you have completed the above steps, click Apply in theActions pane.
How to enable or disable static and dynamic compression for a server
- Open Internet Information Services (IIS) Manager:
- If you are using Windows Server 2008 or Windows Server 2008 R2:
- On the taskbar, click Start, point to Administrative Tools, and then click Internet Information Services (IIS) Manager.
- If you are using Windows Vista or Windows 7:
- On the taskbar, click Start, and then click Control Panel.
- Double-click Administrative Tools, and then double-clickInternet Information Services (IIS) Manager.
- If you are using Windows Server 2008 or Windows Server 2008 R2:
- In the Connections pane, highlight the name of your server.
- In the server's Home pane, double-click Compression.
No comments:
Post a Comment