Fixed a problem with IIS gzip not being enabled properly

  • 2020-05-07 20:41:45
  • OfStack


1. Download and install gzip

Independent host/VPS 1 key open IIS GZIP method / / www ofstack. com article / 30151. htm

2. After the successful installation, it is basically ok. In general, gzip cache directory c:\windows\IIS Temporary CompressedFiles directory is the gzip cache directory.

Just restart iis.


IIS enabled Gzip compression causes OpenFlashChart not to display problems and solutions properly

When
USES the OpenFlashChart control to display a chart in.NET, who would have thought that whether the chart is normal or not would be related to whether the server IIS has Gzip compression enabled?
Both sites use the same set of programs. One site shows the OpenFlashChart chart properly, while the other shows "ioerror Error #2032". The problem only appears in IE6, while firefox and IE7 show it properly.
Baidu and Google1 found that the reason was that the server used Gzip compression optimization website and no-cache appeared at the same time, the solution is to add HTTP header in the returned page, the sample code is as follows:

 
Response.Clear(); 
//Response.CacheControl = "no-cache"; 
// Use this sentence instead of the above 1 other  
Response.AppendHeader("Cache-Control", "no-cache, no-store, must-revalidate, max-age=-1"); 
Response.Write(chart.ToString()); // The output openflashchat flow  
Response.End(); 


below is a detailed introduction, suitable for manual configuration gzip friends

1. HTTP compression overview

HTTP compression is the method of transferring compressed text content between the Web server and the browser. HTTP compression USES common compression algorithms such as gzip to compress HTML, JavaScript, or CSS files. The biggest benefit of compression is that it reduces the amount of data transferred over the network, thus increasing the speed of access to the client browser. Of course, it also adds a little bit of server load. Gzip is a common HTTP compression algorithm.
The HTTP compression method introduced in this paper adopts the mode of Windows system setting, which has the advantage of high efficiency.

2. How HTTP compression works

The Web server handles HTTP compression in the following way:
After the Web server receives the HTTP request from the browser, it checks whether the browser supports HTTP compression.
If the browser supports HTTP compression, the Web server checks the suffix name of the request file.
If the request file is HTML, CSS and other static files, Web server checks whether the latest compressed file of the request file already exists in the compressed buffer directory.
If the compressed file of the request file does not exist, the Web server returns the uncompressed request file to the browser and stores the compressed file of the request file in the compressed buffer directory.
If the latest compressed file of the request file already exists, the compressed file of the request file is returned directly.
If the request file is a dynamic file such as ASPX, the Web server dynamically compresses the content and returns it to the browser. The compressed content is not stored in the compressed cache directory.

gzip does not affect the search engine Seo, and Baidu clearly means that it can parse Gzip data.
We used the tools of the stationmaster station to test the effect after 1 Gzip:

However, notice that GZIP1 only works on text like Html, but not on compressed images like gif,jpg, etc.
Download let's go step by step and show you how to open Gzip of IIS
1. Open Internet information services (IIS) manager, right - click "site" - "properties", and select "services". In the "HTTP compression" box, select "compress application files" and "compress static files", and set the "temporary directory" and "temporary directory maximum limit" as required.

2. In Internet information services (IIS) manager, right click "Web service extensions" - "add a new Web service extension. ", in the "new Web service extension" box, enter the extension name "HTTP Compression", add "required file" as c:\WINDOWS\system32\inetsrv\gzip.

3. Use a text editor to open c:\Windows\System32\inetsrv\ MetaBase.xml (backup is recommended),
Please note before opening:
1. Stop IIS before editing MetaBase.xml. You can use Microsoft key + R to run net stop iisadmin
2. Restart VPS after modification

Find Location = "/ LM/W3SVC/Filters Compression/gzip used to set the gzip compression,
Find Location = "/ LM/W3SVC/Filters Compression/deflate" is used to set deflate compression. The top two nodes are next to each other. And set the same properties.
If dynamic files need to be compressed, set HcDoDynamicCompression to "TRUE",
Add the suffix name of the dynamic file you want to compress to HcScriptFileExtensions, such as aspx.
If you need to compress static files, set HcDoStaticCompression and HcDoOnDemandCompression to "TRUE",
Add static file suffixes that you need to compress in HcFileExtensions, such as xml, css, etc.
HcDynamicCompressionLevel and HcOnDemandCompLevel represent the desired compression rate, with values between 0 and 10, which defaults to 0.
HcDynamicCompressionLevel property description: HcDynamicCompressionLevel Metabase Property
HcOnDemandCompLevel property description: HcOnDemandCompLevel Metabase Property
Description: these two properties are recommended to set the value of 1 to 9, with the best cost performance.

Here's the key configuration: GZIP is not working because the following configuration is not mentioned on the web.

HcNoCompressionForHttp10="TRUE"
HcNoCompressionForProxies="TRUE"
Instead of
HcNoCompressionForHttp10="FALSE"
HcNoCompressionForProxies="FALSE"

Related articles: