The gZip Encoding
Why?
There are two cases of figure:
| • |
When one is FAI, one has an enormous symmetrical band-width directly connected on a backbone. One privileges the machine time with the detriment of the band-width. |
| |
| • |
When one is a private individual or a small structure, compression allows stage a ridiculous band-width in UpLoad. To serve of the compressed Web pages roof, even exceeds, the difference of band-width. |
The gZip Encoding is a method to serve as the Web pages with compression gZip under Linux. The Web navigator sends a request HTTP to the Web server. In this request it can indicate that it accepts the gZip Encoding. HTML Page then will be sent compressed. If the navigator cannot interpret the format gZip, the Web server sends a HTML page not compressed normal. It is in particular the operating mode of Apache 2.x.
Apache 2.x
I will speak to you about the fact that I know well: to be useful with the Apache HTTP Server 2.x bus with the version 1.3.x, the compression of HTML page this fact not with the same module.
With Apache 2.x, it is the mod_deflate module which takes care of compression. In the distribution Fedora FC12 the version installed of Apache is well a httpd 2.2.15.x some is the version chosen, for x86-compatible (32-bit) for Pentium or for x86_64 (64-bit AMD64, EM64T) for Athlon 64. The latter is very powerful for the gZip dynamic Encoding (HTML page compressed with the gZip format with stolen). It is the same for FreeBSD with Apache 2.2.15.x see article :
FreeBSD - Install and Configure version 7.3-RELEASE
FreeBSD - Install and Configure version 8.1-RELEASE
In the version of Apache 2.x the mod_deflate module is already installed, it is simply necessary to activate the gZip Encoding in the file httpd.conf and you will see: nothing simpler.
With an Editor, to open the file httpd.conf who is in The following directory:
For a Linux distribution Fedora /etc/httpd/conf/
For an Unix FreeBSD /usr/local/etc/apache22/
To find the section following:
#
# AddEncoding allows you to have certain browsers uncompress
# information on the fly. Note: Not all browsers support this.
# Despite the name similarity, the following Add* directives have nothing
# to do with the FancyIndexing customization directives above.
# |
|
AddEncoding x-compress .Z
AddEncoding x-gzip .gz .tgz
|
Here on the two lines to remove character # to activate the gZip Encoding. |
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
# |
|
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
|
|
AddOutputFilterByType DEFLATE text/php text/HTML text/txt
#
|
To add this line to compress with the gZip format only the extensions of following HTML page: .php .html .txt |
Here: it is all that it is necessary to do!
For check if your Apache HTTP Server sends well a gZip Encoding, to take FireFox Mozilla or Safari, finally a Web navigator of the family Gecko bus although the navigator of the Redmond firm manages very well file gZip Encoding of the format, it posts only the weight of the uncompressed page. To charge a URL of your site, to make clicks right in the Web page, to select View Page Info and you will have the weight of the of the page gZip file, to compare with the size of the page gZip file on the disc.
Another method of checking:
With Apache, the log format which is appropriate very well for Webalizer:
"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""
As in the following example of log, the number indicated here in orange which gives the size of the compressed file:
192.168.1.1 - - [16/Sep/2008:10:20:40 +0200] "GET /fr/article.php?AIndex=30 HTTP/1.1" 200 4532 "-" "Mozilla/5.0 (X11; U; FreeBSD i386; fr-FR; rv:1.8.1.16) Gecko/20080911 Firefox/2.0.0.16"
Size of the compressed File for this Web page 4,43 Ko (4532 octets) and the size of the file on Disk is from 15,3 Ko (15650 octets).
|