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

How to set up Gzip and squid in apache2

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article introduces the knowledge of "how to set up Gzip and squid in apache2". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Gzip can be a big accelerated website. Sometimes the compression ratio is as high as 80%. Recently, it has been tested that it is at least more than 40%, which is quite good. In versions after Apache2, the module name is not gzip, but mod_deflate

If you want to open gzip, be sure to open the following two modules.

LoadModule headers_module modules/mod_headers.so

LoadModule deflate_module modules/mod_deflate.so

Set the compression ratio, which ranges from 1 (minimum) to 9 (maximum). It is not recommended to set too high, although it has a high compression ratio, it takes up more CPU resources.

DeflateCompressionLevel 3

AddOutputFilter DEFLATE html xml php js css

SetOutputFilter DEFLATE

BrowserMatch ^ Mozilla/4 gzip-only-text/html

BrowserMatch ^ Mozilla/4\ .0 [678] no-gzip

BrowserMatch\ bMSIE! no-gzip! gzip-only-text/html

SetEnvIfNoCase Request_URI\. (?: gif | jpe?g | png) $no-gzip dont-vary

SetEnvIfNoCase Request_URI. (?: exe | t?gz | zip | bz2 | sit | rar) $no-gzip dont-vary

SetEnvIfNoCase Request_URI. (?: pdf | mov | avi | mp3 | mp4 | rm) $no-gzip dont-vary

The setting of the agent by Header append Vary User-Agent envails dontmuri

The following two test sites

Http://www.whatsmyip.org/mod_gzip_test/

Http://www.gidnetwork.com/tools/gzip-test.php

Test data pair css

Original Size: 44 KB

Gzipped Size: 10 KB

Data Savings: 77.27%

Test data js

Original Size: 6 KB

Gzipped Size: 2 KB

Data Savings: 66.67%

Test data php

Original Size: 62 KB

Gzipped Size: 15 KB

Data Savings: 75.81%

The above is just a few random data, you can see that the use of gzip compression after the file is much smaller.

By the way, about squid's handling of gzip.

In squid, only one cache is reserved for the same URL. For frequent alternate accesses if different browser (whether compression is supported), for example, for a target where a cache resides, an http/1.0 request may cause the squid to force its cache to be updated. But another http/1.1 request causes squid to update the cache again. In this way, the squid cache data has to be updated frequently, which greatly reduces the cache hit rate.

Fortunately, it is rare that browser does not support compression in the real world, so the reduction of cache hit rate is very limited.

That's all for "how to set up Gzip and squid in apache2". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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