Web pages enable gzip compression to improve browsing speed

Source: Internet
Author: User
Tags metabase

1. What are the benefits of opening gzip?

A: When Gzip is turned on, the data exported to the user's browser will be compressed, which will reduce the amount of data transmitted over the network and improve the speed of browsing.

2. How to enable the Gzip compression feature for IIS:

A: First, if you need to compress the static file (HTML), you need to build a directory on the hard disk, and give it "IUSR_ machine name" This user's write permissions. If the compressed dynamic file (php,asp,aspx) is not needed, because its pages are dynamically generated each time, the compression is discarded. Then in IIS Manager, the "Web site" right-click Property, not one of the following sites, but the entire site. Go to the "Services" tab, select Enable dynamic content compression, static content compression. Then select the server extension below the site to create a new server extension. The name does not matter, the following path to add the file is: C:\windows\system32\inetsrv\gzip.dll, and then enable this extension. Static content can be compressed at this time, but for dynamic content, the ASPX file is not in the compressed range. Because the default compressible file does not have this extension. And in the management interface you can not find a place to add extensions, this time only to modify its configuration file. Under the c:\windows\system32\inetsrv\ there is a MetaBase.xml file, you can open it with Notepad, find IIsCompressionScheme, there are three identical names of the segment, is Deflate,gzip, Parameters, the third paragraph does not need to control it, the first two paragraphs have the same parameters, in the two paragraphs of the parameters hcscriptfileextensions below all add a line of ASPX, if you have other dynamic program to compress, also add here. HcDynamicCompressionLevel changed to 9, (0-10,9 is the most cost-effective one). Then you need to restart the IIS service, you can experience the speed of compression.

Gzip compression I started it early, but I never shared it with you. Recently due to the issue of filing, temporarily replaced the server, the results forgot to enable gzip compression, the weekend use free time to enable the gzip compression, and the entire process recorded, share with you.

Benefits of enabling GZIP compression

Its benefits are obvious, improving the speed of web browsing, whether it was previously said to streamline the code, compressing the picture is not as good as gzip enabled. The effect after gzip is enabled.

Gzip compression efficiency is very high, usually can achieve 70% compression ratio, that is, if your Web page has 30K, compression after the turn into 9K or so.

First step: Open IIS, enable HTTP compression service

Right-click Site, properties, and select Services. Select "Compress application Files" and "Compress static files" in the "HTTP Compression" box, set "Temp directory" and "Maximum limit of temporary directory" as required;

Step two: Enable Web services

Step Three: Modify MetaBase.xml

Start > Run input c:\windows\system32\inetsrv, find Metebase.xml, first back up, in modify. (Some servers do not need to modify this file to be used)

Search location = "/lm/w3svc/filters/compression/gzip"

Carefully check the code:

 <iiscompressionscheme location = "/lm/w3svc/filters/compression/deflate"
hccompressiondll= "%windir %\system32\inetsrv\gzip.dll "
hccreateflags=" 0 "
hcdodynamiccompression=" TRUE "
hcdoondemandcompression= "TRUE"
hcdostaticcompression= "FALSE"
hcdynamiccompressionlevel= "0"
hcfileextensions= "htm
HTML
TXT "
hcondemandcomplevel="
hcpriority= "1"
hcscriptfileextensions= "ASP
DLL
EXE"
>
</IIsCompressionScheme>
<iiscompressionscheme location = "/lm/w3svc/filters/compression/gzip"
Hccompressiondll= "%windir%\system32\inetsrv\gzip.dll"
hccreateflags= "1"
hcdodynamiccompression= "TRUE"
Hcdoondemandcompression= "true"
Hcdostaticcompression= "true"
hcdynamiccompressionlevel= "0"
hcfileextensions= "htm
HTML
txt"
hcondemandcomplevel= "
hcpriority=" 1 "
hcscriptfileextensions= "ASP
DLL
EXE"
>
</iiscompressionscheme>

replaced by:

<iiscompressionscheme location = "/lm/w3svc/filters/compression/gzip"
hccompressiondll= "%windir%\ System32\inetsrv\gzip.dll "
hccreateflags=" 1 "
hcdodynamiccompression=" TRUE "
hcdoondemandcompression=" True "
Hcdostaticcompression=" true "
hcdynamiccompressionlevel="
hcfileextensions= "HTML
CSS
JS
htm
XML
txt "
hcondemandcomplevel="
hcpriority= "1"
hcscriptfileextensions= "PHP
DLL"
>
</IIsCompressionScheme>
<iiscompressionscheme location = "/lm/w3svc/filters/compression/ Deflate "
hccompressiondll="%windir%\system32\inetsrv\gzip.dll "
hccreateflags=" 2 "
Hcdodynamiccompression= "true"
Hcdoondemandcompression= "true"
Hcdostaticcompression= "true"
Hcdynamiccompressionlevel= "Ten"
hcfileextensions= "HTML
CSS
JS
htm
XML
txt"
Hcondemandcomplevel= "Ten"
hcpriority= "1"
hcscriptfileextensions= "PHP
DLL"
>
</ Iiscompressionscheme>

After you modify it, stop the IIS Admin Service services in the service.

Then, after saving the Metebase.xml, save it and start IIS again. This enables the GZIP compression to be enabled successfully.

Finally, test gzip compression is successful, you can go to Webmaster Tools http://tool.chinaz.com/Gzips/to detect.

Tips:

This article is only demonstrated on the Windows IIS server, VPS host, standalone server can be implemented, virtual host users need to consult the space quotient (General virtual host has gzip enabled)

Web pages enable gzip compression to improve browsing speed

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.