Windows Apache opens GZIP

Source: Internet
Author: User

From the server-side optimization, the size of the text file can be greatly reduced by compressing the server, so that the speed of loading is multiplied. Currently, a more general compression method is to enable gzip compression. It sends the page that the browser requests, as well as the static resources referenced in the page, to the client in the form of a compressed package, and then completes the decompression and assembly on the client. The implementation does not care, we just have to enable the Gzip. Use the tool to detect the effect of not turning on page compression. The following steps let us specifically turn on Apache-based gzip compression support.

Detection tools:

http://www.whatsmyip.org/http-compression-test/?url=d3d3LmZlbmd6aWdhbWUuY29t

The Firebug of Firefox

Implementation steps

1. Locate and open the httpd.conf file in the apache/conf directory

Open the Deflate_module and Headers_module modules in 2.httpd.conf by removing the following two lines in front of them:

LoadModule Deflate_module modules/mod_deflate.so

LoadModule Headers_module modules/mod_headers.so

3. At the bottom of the httpd.conf file, add the following code to configure the files that need to be compressed:

<ifmodule mod_deflate.c>setoutputfilter Deflateaddoutputfilterbytype Deflate Text/plainaddoutputfilterbytype DEFLATE text/htmladdoutputfilterbytype DEFLATE text/phpaddoutputfilterbytype DEFLATE text/xmladdoutputfilterbytype DEFLATE text/cssaddoutputfilterbytype DEFLATE text/javascriptaddoutputfilter DEFLATE js Cssaddoutputfilterbytype DEFLATE application/xhtml+xmladdoutputfilterbytype DEFLATE application/xmladdoutputfilterbytype DEFLATE Application /rss+xmladdoutputfilterbytype DEFLATE application/atom_xmladdoutputfilterbytype DEFLATE application/ X-javascriptaddoutputfilterbytype DEFLATE application/x-httpd-phpaddoutputfilterbytype DEFLATE image/svg+ Xmladdoutputfilterbytype DEFLATE image/gif image/png image/jpe image/swf image/jpeg image/bmp# Don ' t compress images and Other #排除不需要压缩的文件BrowserMatch ^MOZILLA/4 gzip-only-text/htmlbrowsermatch ^mozilla/4\.0[678] no-gzipbrowsermatch \ Bmsie!no-gzip!gzip-only-text/htmlsetenvifnocase Request_uri. (?: html|htm) $ no-gzip Dont-varysetenviFnocase #SetEnvIfNoCase Request_uri. (?: gif|jpe?g|png) $ no-gzip dont-varysetenvifnocase Request_uri. (?: Exe|t?gz|zip|bz2|sit|rar) $ no-gzip dont-varysetenvifnocase Request_uri. (?:p df|doc) $ no-gzip dont-vary</ifmodule>

4. Restart Apache Server

Second, the Web server processing

The process of HTTP compression is as follows:

After the Web server receives the browser's HTTP request, check to see if the browser supports HTTP compression (accept-encoding information);

If the browser supports HTTP compression, the Web server checks the suffix name of the requested file;

If the request file is an HTML, CSS and other static files, the Web server to the compression buffer directory to check whether the requested file has the latest compressed file;

If the compressed file of the requested file does not exist, the Web server returns the uncompressed request file to the browser and stores the compressed file of the requested file in the compressed buffer directory;

If the most recent compressed file of the requested file already exists, the compressed file of the requested file is returned directly;

If the request file is a dynamic file, the Web server dynamically compresses the content and returns the browser, and the compressed content is not stored in the compressed cache directory.

Iv. What are the main differences between Mod_gzip and mod_deflate? (from the Internet)

The first difference in

is the version of the Apache Web server on which they are installed. The Apache 1.x series does not have built-in Web page compression technology, so it uses additional third-party mod_gzip modules to perform compression. While the Apache 2.x official in the development of the time, the page compression into account, built a mod_deflate This module, to replace the mod_gzip. Although both are used by the GZIP compression algorithm, they operate in a similar principle. The second difference is the compression quality. Mod_deflate compression speed slightly faster and mod_gzip compression ratio is slightly higher. Generally, by default, Mod_gzip will be 4%~6% more compressed than mod_deflate. So, why use mod_deflate? The third difference is the use of server resources. Generally speaking, Mod_gzip is a bit more expensive for server CPUs. Mod_deflate is a compression module specifically designed to ensure server performance, and mod_deflate requires less resources to compress files. This means that on high-traffic servers, using mod_deflate may load faster than Mod_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.