Apache Web page Compression

Source: Internet
Author: User
Tags control label

Overview of compression features
Configuring Apache Web page compression is the use of the Gzip compression algorithm to compress the content of Web pages published by the Apache server before being transferred to the client browser.

Advantages of Web Compression
Speed up Web page loading and improve user's browsing experience
Reduces network transmission bandwidth and server saves traffic
Web page compression facilitates search engine crawling

Page Compression Module classification
Apache can achieve Web page compression function module has mod_gzip module and Mod_deflate module. The apache1.x series does not have built-in Web page compression technology, but you can use additional third-party mod_gzip modules to perform compression. Apache 2.x series official in the release, the page compression function into account, built mod_deflate This module, used to replace the Mod_gzip module


Enable Web page compression feature

[Email protected] ~]# apachectl-d dump_modules

Loaded Modules:
Core_module (Static)
Authn_file_module (Static)
Authn_default_module (Static)
Authz_host_module (Static)
Authz_groupfile_module (Static)
Authz_user_module (Static)
Authz_default_module (Static)
Auth_basic_module (Static)

......
Syntax OK
[Email protected] ~]# apachectl-t-D dump_modules | The grep deflate//-t option does not add
Syntax OK
[Email protected] ~]# apachectl-d dump_modules | grep deflate
Syntax OK

Deflate_module (Static) not installed, recompile installation

[[Email protected] ~]# service httpd stop

[Email protected] ~]# cd/usr/src/httpd-2.2.31/

[Email protected] httpd-2.2.31]#/configure--prefix=/usr/local/httpd/--enable-so--enable-
Rewrite--enable-charset-lite--enable-cgi --enable-deflate && make && make install

[Email protected] ~]# apachectl-d dump_modules | grep deflate
Deflate_module (Static)
Syntax OK

[[Email protected] ~]# service httpd start

For ease of comparison, use the Fiddler tool to grab the package before enabling the module

Configure cache time for Web pages

Configuring page Cache Time Overview 

Apache is configured via the Mod_expires module to allow Web pages to be cached in the client browser for a period of time to avoid duplicate requests and reduce service-side work stress.

When the Mod_expires module is enabled, the expires label and the Cache-control label in the header information of the page are automatically generated, reducing the frequency and number of visits to the client to reduce unnecessary traffic and increase access speed.

Enable the Web caching feature

See if the Mod_expires module is installed

[Email protected] ~]# apachectl-d dump_modules | grep expires
Syntax OK

Expires_module (Static) not installed, recompile installation

[[Email protected] ~]# service httpd stop

[Email protected] ~]# cd/usr/src/httpd-2.2.31/

[Email protected] httpd-2.2.31]#/configure--prefix=/usr/local/httpd
/--enable-so--enable-rewrite--enable-charset-lite--enable-cgi--enable-deflate--enable-
Expires && make && make install

[Email protected] ~]# apachectl-d dump_modules | grep expires
Expires_module (Static)
Syntax OK

[[Email protected] ~]# service httpd start

For ease of comparison, use the Fiddler tool to grab the package before enabling the module

Modify the configuration file enable caching feature
At the end of the httpd.conf master configuration file, add the following:

[Email protected] ~]# vim/usr/local/httpd/conf/httpd.conf

423 <ifmodule mod_expires.c>
424 expiresactive on//Turn on the Web caching function
425 ExpiresDefault "Access plus seconds"//http protocol the next document expires after 60 seconds
426 </IfModule>

Apache Web page Compression

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.