Content Highlights:
Apache Web Optimization
Compression Overview page and Features
Web cache Overview and Features
A, Apache Page Optimization Overview
1, in the enterprise, only after the deployment of Apache default configuration parameters, can cause a lot of problems the site, in other words the default configuration is configured for low before the server, previous configuration no longer applicable in today's Internet age
2, in order to meet business needs, we need to consider how to enhance the performance and stability of the Apache, which is Apache optimized content
3, optimizing content
Configuration page compression
Operating mode selection and parameter optimization
Configuring security chain
Hide the version number of the configuration
Two, gzip introduction
Configuring Apache Web compression, using gzip compression algorithm to compress and then transmit the content of pages to the client browser
effect
Reduce the number of bytes transmitted over the network, speed up page load
Save traffic, improve the user's browsing experience
gzip and search engine crawlers have a better relationship
Three, Apache compression modules
1, Apache web to achieve compression function module comprises
mod_ gzip module
mod_ deflate module
2、Apache 1.x
No built-in web compression, but the third party E mod_ gzip compression module may be performed using
3、Apache 2.x
During development, built mod_ deflate this module, replace mod_ gzip
4, mod_ gzip module and module mod_ _deflate
Both use gzip compression algorithm, similar to how it works
mod_ deflate compression slightly faster, but mod_ gzip compression ratio is slightly higher
mod_gzip occupation of the server CPU is higher - - some
High-traffic server, using mod_ deflate may be faster than the speed of loading mod_ _gzip
Fourth, the configuration web page compression
1, enable web compression step
Check module is installed mod_deflate
Modify the configuration file compression is enabled
Ethereal test
2, first check if the module is installed mod_ _deflate
Execute apachectl -t -D DUMP_ MODULES command
If the output is not deflate_ module (static), no instructions when compiling module installed mod_ deflate
3. If you do not have to re-install to compile and install
./configure --enable-deflate... make && make install
4, arranged in the open configuration the httpd.conf function gzip
AddOutputFilterByType DEFLATE text/html text/plain text/csstext/xml text/javascript DeflateCompressionlevel SetOutputFilter DEFLATE
The first row represents Enable gzip compression for what kind of content
The second line represents the compression level
The third line represents the output of the module is enabled deflate this site are gzip compression
5, restart the Apache service, browser and then access the test site, and capture tool with Fiddler, comparative analysis
Fifth, configure the cache time for web pages
1, the configuration module Apache mod_ expire by the web browser on the client can cache a period of time, to avoid duplication request
2, mod_ expire enabled module, automatically generates a page header information and Cache-Control Expires label tag, thereby reducing the number and frequency of the client, to reduce unnecessary traffic and increasing access speed purposes
3, enable web caching feature step
Check module is installed mod_expire
Modify the configuration file caching feature is enabled
Ethereal test
4, to see if the module is installed mod_ expire
/usr/local/apache/bin/apachectl -t -D DUMP_ MODULES
If the output is not expires_ module (static), then there is no compile-time installation mod_ expires
If you do not have to re-compile and install
./configure --enable-expires... make && make install
5, modify the configuration file httpd.conf
启用mod_ expires模块, 并设置http协议下任意格式的文档均60秒后过期
<lfModule mod_ expires.c> ExpiresActive On ExpiresDefault "access plus 60 seconds" </fModule>
6、重启httpd服务
systemctl restart httpd
7、再次访问测试网站,使用抓包工具Fiddler进行数据抓取分析
以上就是apache网页压缩缓存的所有操作步骤。
更多apache优化,进我主页查看。