Iis7.5 gzip compression Configuration

Source: Internet
Author: User

Enable HTTP compression (gzip)

Configuration of gzip compression in iis7 is much easier than IIS6, and gzip compression is enabled by default. If no, you can find the "compression" option in the function view. after entering the option, you will see the "static content compression" and "dynamic content compression" options.

Enable the compressed file type and other options

after gzip compression is enabled, IIS does not enable compression for all content, but has a choice for compression. Unfortunately, we cannot directly configure these compression options in the iis7 manager. You must first find applicationhost in the C:/Windows/system32/inetsrv/config folder. after opening the config file, find the following content:

 
   
   













We can see that IIS determines whether to enable HTTP compression and the compression ratio based on the MIME type. We can see that the image is not compressed by default, becauseThe image compression ratio is too low.

We noticed that for Javascript, different compression methods are configured for different MIME types. Javascript has three common MIME types: text/JavaScript, application/X-JavaScript, and application/JavaScript. These three types are legal and there is no difference in modern browsers. HoweverIn iis7, the MIME type of JS files is set to application/X-JavaScript by default. That is to say, for JS files, dynamic content compression is used instead of static content compression, therefore, JavaScript files are sometimes compressed but sometimes not compressed.

Since JavaScript files are usually stable and will not be modified, we recommend that you change them to Static Compression-that is, transfer application/X-Javascript in dynamictypes to the static compression section. This ensures that each script is compressed and returned.

Differences between static compression and dynamic compression

HTTP compression in iis7 is divided into "static content compression" and "dynamic content compression". In fact, these two names are confusing for the first time. What is dynamic content and static content? In fact, accurate translation should be "Static Compression" and "dynamic compression ". These two words reflect the compression behavior of IIS. Static Compression is enabled for MIME types configured in the statictypes section. That is, when a file is requested for the first time, IIS compresses the file and puts it in a temporary folder, the next time someone requests this file, the compressed version is taken out of the Temporary Folder without re-executing the compression process. All mime-Type HTTP requests configured in the dynamictypes section Enable dynamic compression. That is, each request is sent to the host, which may be static files stored in the file system, it may also be that the content returned by the ISAPI is compressed without being slowed down. This compression ratio will be adjusted because of different host performance. Therefore, when we request JavaScript files, we will find that JavaScript files are sometimes compressed and sometimes not compressed.

Obviously, static compression occupies a certain amount of storage space, but the speed is fast. Dynamic compression does not occupy storage space, but consumes CPU time, and the compression ratio is not constant. For ISAPI requests, static compression is not allowed. For example, for the content returned by WCF.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.