Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Apache Web Page Compression and caching

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Main points of content:

Apache web page optimization

Overview of web page compression and introduction of its functions

Overview and functional introduction of Web caching

I. Overview of Apache web page optimization

1. In enterprises, only the default configuration parameters are used after the deployment of Apache, which will cause a lot of problems on the website. In other words, the default configuration is for the lower servers in the past, and the previous configuration is no longer suitable for today's Internet era.

2. In order to meet the needs of enterprises, we need to consider how to improve the performance and stability of Apache, which is the content of Apache optimization.

3. Optimize the content

Configure web page compression

Selection of working mode and parameter optimization

Configure hotlink protection

Configure hidden version number

II. Introduction to gzip

Configure Apache's web page compression function, which uses the gzip compression algorithm to compress the web page content and then transfer it to the client browser.

Action

Reduces the number of bytes transmitted through the network and speeds up the loading speed of web pages.

Save traffic and improve users' browsing experience

Gzip has a better relationship with the crawling tools of search engines.

III. Compression module of Apache

1. The functional modules of Apache to realize web page compression include

Mod_ gzip module

Mod_ deflate module

2 、 Apache 1.x

There is no built-in web page compression technology, but compression can be performed using the third E mod _ gzip module

3 、 Apache 2.x

At the time of development, the module mod_ deflate is built in to replace mod_ gzip

4. Mod_ gzip module and mod_ _ deflate module

Both of them use gzip compression algorithm, which works similarly.

Mod_ deflate compression speed is slightly faster, while mod_ gzip compression ratio is slightly higher.

Mod_gzip takes up more server CPU-- a little bit.

For high traffic servers, using mod_ deflate may load faster than mod_ _ gzip

Fourth, configure the web page compression function

1. Steps to enable web page compression

Check to see if mod_deflate module is installed

Modify the configuration file to enable compression

Bag grab test

2. First check whether the mod_ _ deflate module is installed

Execute the apachectl-t-D DUMP_ MODULES command

If there is no deflate_ module (static) in the output, the mod_ deflate module is not installed at compile time

3. If there is no installation, recompile the installation

. / configure-- enable-deflate...make & & make install

4. Configure and enable the gzip function in the configuration httpd.conf

AddOutputFilterByType DEFLATE text/html text/plain text/csstext/xml text/javascriptDeflateCompressionlevelSetOutputFilter DEFLATE

The first line represents what gzip compression is enabled for.

The second line represents the compression level

The third line represents enabling the deflate module to compress the output of this site with gzip.

5. Restart the Apache service, then visit the test website with a browser, and grab the package with Fiddler tools for comparative analysis.

Fifth, configure the caching time of web pages

1. Configure Apache through the mod_ expire module so that the web page can be cached in the client browser for a period of time to avoid repeated requests.

2. When the mod_ expire module is enabled, the Expires tag and Cache-Control tag in the header information of the page are automatically generated, thus reducing the access frequency and times of the client, reducing unnecessary traffic and increasing the access speed.

3. Steps to enable web page caching

Check to see if mod_expire module is installed

Modify the configuration file to enable caching

Bag grab test

4. Check whether the mod_ expire module is installed

/ usr/local/apache/bin/apachectl-t-D DUMP_ MODULES

If there is no expires_ module (static) in the output, mod_ expires is not installed at compile time

If there is no installation, recompile the installation

. / configure-- enable-expires...make & & make install

5. Modify httpd.conf configuration file

Enable mod_ expires module and set documents in any format under http protocol to expire in 60 seconds

ExpiresActive On ExpiresDefault "access plus 60 seconds"

6. Restart the httpd service

Systemctl restart httpd

7. Visit the test website again and use the package crawling tool Fiddler for data crawling and analysis.

These are all the steps for compressing the cache of apache pages.

For more apache optimization, check out my home page.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report