Reasons for IIS enabling gzip compression CSS file invalidation and resolution

Source: Internet
Author: User

IIS enabled gzip compression, the original thought you can compress all the files, including HTML, CSS, JS, pictures of these files, but when I check, I found that is not the case, compressed only HTML files, and CSS, JS and not compression.

Detection results in the speed diagnostics of the Web site of the card network:

The HTML page has successfully enabled gzip compression

The CSS file was not successfully enabled for GZIP compression

Later, the study found that IIS enabled gzip when the default compression of only HTML pages, if you need to compress CSS, JS and other files, but also need to configure a simple file.

Open C:windowssystem32inetsrvmetabase.xml This file, and then look for "IIsCompressionScheme", will find that there are three paragraphs, the back of the tube, only set the front two can be. where "/lm/w3svc/filters/compression/gzip" is used to set gzip compression, and "/lm/w3svc/filters/compression/deflate" is used to set deflate compression.

If you want to compress static files, set HcDoStaticCompression and HcDoOnDemandCompression to "TRUE" and add the static files that need to be compressed in the HcFileExtensions properties: CSS, JS, etc.

To compress the dynamic files, set HcDoDynamicCompression to TRUE and add the dynamic files that need to be compressed in the HcScriptFileExtensions attribute: aspx, PHP, and so on.

In addition, the HcDynamicCompressionLevel property and HcOnDemandCompLevel properties are generally recommended to set to 9, with the best price/performance.

Refer to the following parameter settings:

The code is as follows Copy Code

<iiscompressionscheme Location = "/lm/w3svc/filters/compression/deflate"
Hccompressiondll= "%windir%system32inetsrvgzip.dll"
hccreateflags= "0"
hcdodynamiccompression= "TRUE"
hcdoondemandcompression= "TRUE"
hcdostaticcompression= "TRUE"
Hcdynamiccompressionlevel= "9"
hcfileextensions= "htm
Html
Txt
Css
Js
xml
Hcondemandcomplevel= "9"
hcpriority= "1"
hcscriptfileextensions= "ASP
aspx
Dll
Exe
>
</IIsCompressionScheme>
<iiscompressionscheme Location = "/lm/w3svc/filters/compression/gzip"
Hccompressiondll= "%windir%system32inetsrvgzip.dll"
hccreateflags= "1"
hcdodynamiccompression= "TRUE"
hcdoondemandcompression= "TRUE"
hcdostaticcompression= "TRUE"
Hcdynamiccompressionlevel= "9"
hcfileextensions= "htm
Html
Txt
Css
Js
xml
Hcondemandcomplevel= "9"
hcpriority= "1"
hcscriptfileextensions= "ASP
aspx
Dll
Exe
>
</IIsCompressionScheme>

After setting up, restart IIS, and then detect when the CSS, JS and other files have been successfully enabled Gzip.

Related Article

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.