Before the article, many new webmasters know that the speed of Website access only exists in the selection of servers and templates. In fact, Gzip web page compression can greatly increase the speed of Website access, this is an essential step for websites outside of China, and the speed of website opening is very obvious. Now we will take a look at the true nature of Gzip from the system.
1. What is GZIP?
GZIP Concept
GZIP was first created by Jean-loup Gailly and Mark Adler for File compression in the un ix system. We often use files suffixed with .gz in linux, which are in GZIP format. Nowadays, it has become a widely used data compression format on the Internet, or a file format.
GZIP encoding on HTTP is a technology used to improve the performance of WEB applications. Large-Traffic WEB sites often use GZIP compression technology to make users feel faster. This generally refers to a function installed on the WWW server. When someone visits the website on this server, this function in the server compresses the webpage content and then transmits it to the visiting Computer Browser for display. generally, the plain text content can be compressed to 40% of the original size. in this way, the transmission is faster, and the result is that you click the URL and it will be displayed soon. of course, this will also increase the server load. this function module is installed on servers.
2. What are the benefits of enabling GZIP?
After Gzip is enabled, the data output to the user's browser is compressed, which reduces the amount of data transmitted over the network and improves the browsing speed. Gzip can greatly accelerate the website. Sometimes the compression ratio is as high as 80%, with at least 40%.
3. How to enable Gzip compression.
1. IIS:
First open IIS, right-click on the website and choose service,
Select the two options in HTTP compression. The default C directory can be used for the temporary directory. If the C disk space is tight, you can create it yourself. Note that you need to grant the write permission to "IUSR _ machine name" for this directory. Otherwise, Gzip cannot be enabled normally. At the same time, if you do not have enough space, you can limit the directory capacity. Otherwise, the temporary files here will be big and scary for sites with high traffic.
Step 2: Right-click iis web Service Extension
With any extension, select c: windowssystem32inetsrvgzip. dll as the file location, and check "set extension status to allow ".
At this point, some webmasters will start GZIP, but some still need to manually modify the configuration, so we can continue to look down
Step 3: Open the c: windowssystem32inetsrv folder, find MetaBase. xml, copy the backup file, and open the file in notepad.
Search for Location = "/LM/W3SVC/Filters/Compression/gzip"
There are three segments with the same name, namely deflate, gzip, and Parameters.
..
..
..
Here we only need to modify the first two parts. Here we should note whether MetaBase. xml has the write permission, otherwise it cannot be saved:
HcCompressionDll = "% windir % system32inetsrvgzip. dll"
HcCreateFlags = "0"
HcDoDynamicCompression = "TRUE"
HcDoOnDemandCompression = "TRUE"
HcDoStaticCompression = "FALSE"
HcDynamicCompressionLevel = "0"
HcFileExtensions = "htm
Html
Txt"
HcOnDemandCompLevel = "10"
HcPriority = "1"
HcscriptFileExtensions = "asp
Dll
Exe"
>
HcCompressionDll = "% windir % system32inetsrvgzip. dll"
HcCreateFlags = "1"
HcDoDynamicCompression = "TRUE"
HcDoOnDemandCompression = "TRUE"
HcDoStaticCompression = "TRUE"
HcDynamicCompressionLevel = "0"
HcFileExtensions = "htm
Html
Txt"
HcOnDemandCompLevel = "10"
HcPriority = "1"
HcscriptFileExtensions = "asp
Dll
Exe"
>
Replace
HcCompressionDll = "% windir % system32inetsrvgzip. dll"
HcCreateFlags = "1"
HcDoDynamicCompression = "TRUE"
HcDoOnDemandCompression = "TRUE"
HcDoStaticCompression = "TRUE"
HcDynamicCompressionLevel = "10"
HcFileExtensions = "html
Css
Js
Htm
Xml
Txt"
HcOnDemandCompLevel = "10"
HcPriority = "1"
HcscriptFileExtensions = "php
Dll"
>
HcCompressionDll = "% windir % system32inetsrvgzip. dll"
HcCreateFlags = "2"
HcDoDynamicCompression = "TRUE"
HcDoOnDemandCompression = "TRUE"
HcDoStaticCompression = "TRUE"
HcDynamicCompressionLevel = "10"
HcFileExtensions = "html
Css
Js
Htm
Xml
Txt"
HcOnDemandCompLevel = "10"
HcPriority = "1"
HcscriptFileExtensions = "php
Dll"
>
Do not save after replacement. Open the service, stop IIS, click Save, and start IIS, HTTL, and www services.
You can enable Gzip for both the VPS and server according to the preceding steps. The VM needs to ask the service provider.
2. Apache Activation
First, check whether the mod_deflate.so module is loaded in apache. If not, install and load the module. Find and download the source code file that is the same as the current apache version, decompress it to the/home directory, and run the following command in the apache installation directory:
/Usr/local/apache2/bin/apxs-I-c/home/httpd-2.0.63/modules/filters/mod_deflate.
Will be automatically added in httpd. conf
LoadModule deflate_module modules/mod_deflate.so
Add the following settings:
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^ Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^ Mozilla/4.0 [678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch bMSIE! No-gzip! Gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.59
# The above regex won't work. You can use the following
# Workaround to get the desired effect:
# BrowserMatch bMSIE! No-gzip! Gzip-only-text/html force-gzip
BrowserMatch bMSIE! No-gzip! Gzip-only-text/html
# Don't compress images and other
SetEnvIfNoCase Request_URI .(? : Gif | jpe? G | png) $ no-gzip dont-vary
SetEnvIfNoCase Request_URI .(? : Exe | t? Gz | zip | bz2 | sit | rar) $ no-gzip dont-vary
SetEnvIfNoCase Request_URI .(? : Pdf | doc) $ no-gzip dont-vary
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
AddOutputFilterByType DEFLATE application/x-javascript
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env =! Dont-vary
# DeflateFilterNote ratio ratio_info
# Logformat' "% v % h % l % u % t" % r "%> s % B" % {Referer} I "" % {User-Agent} I "" (% {ratio} n) 'deflate
# CustomLog logs/deflate_log deflate
Stop apache service./apachectl stop. The following error is returned:
Cannot load/usr/local/apache2/modules/mod_deflate.so into server:/usr/local/apache2/modules/mod_deflate.so: undefined symbol: deflate
The solution is as follows:
Vi/usr/local/apache2/bin/apr-config
Change LDFLAGS = "" To LDFLAGS = "-lz"
Stop the service: the following message is displayed:
DeflateFilterNote not allowed here
CustomLog not allowed here
After being commented out, it is normal.
The above is the general step for GZIP to be enabled. You can test it on the webmaster tool station. Both the webmaster station and love station have them. Gzip is required.
Fourth, the spider crawling problems circulating on the Internet after Gzip is enabled are basically aimed at dynamic sites, and the static site Gzip is absolutely safe. I hope that dynamic sites will not be easily enabled. Well, start your Gzip journey.
Yayang network www.c9dy.com