In Apache HTTP Server, how does one configure mod_deflate?

Source: Internet
Author: User

First load Module

Loadmodule deflate_module modules/mod_deflate.so

Configuration method in Apache:

<Ifmodule deflate_module>

<Location/>

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

Browsermatch ^ Mozilla/4/. 0 [678] No-Gzip

Browsermatch/bmsi [e]! No-gzip! Gzip-only-text/html

Setoutputfilter deflate

Addoutputfilterbytype deflate text/HTML text/plain text/XML text/CSS text/JavaScript

Setenvifnocase request_uri /.(? : GIF | JPG | cab | jpe? G | exe | BMP | MP3 | RAR | zip | SWF | PNG) $ no-gzip dont-vary

Header append vary User-Agent

</Location>

# Declare the number of bytes of the input stream

Deflatefilternote input instream

# Declare the number of bytes of the output stream

Deflatefilternote output outstream

# Declare the compression percentage

Deflatefilternote ratio Ratio

# Declare the Log Type

Logformat '% t "% R" % {outstream} n/% {instream} n (% {ratio} n %)' deflate

Customlog logs/deflate_log deflate

</Ifmodule>

You can also make the following simple configuration:

<Ifmodule deflate_module>

Setoutputfilter deflate

Addoutputfilterbytype deflate text/HTML text/plain text/XML text/CSS text/JavaScript

Setenvifnocase request_uri /.(? : GIF | JPG | cab | jpe? G | exe | BMP | MP3 | RAR | zip | SWF | PNG) $ no-gzip dont-vary

# Declare the number of bytes of the input stream

Deflatefilternote input instream

# Declare the number of bytes of the output stream

Deflatefilternote output outstream

# Declare the compression percentage

Deflatefilternote ratio Ratio

# Declare the Log Type

Logformat' "% R" % {outstream} n/% {instream} n (% {ratio} n %) 'deflate

Customlog logs/deflate_log deflate

</Ifmodule>

The following configurations can be used in ibm http Server:

<Location/>

Setoutputfilter deflate

Addoutputfilterbytype deflate text/HTML text/plain text/XML text/CSS text/JavaScript

Setenvif User-Agent ^ Mozilla/4 gzip-only-text/html

Setenvif User-Agent ^ Mozilla/4/. 0 [678] No-Gzip

Setenvif User-Agent/bmsie! No-Gzip

Setenvif User-Agent/bmsie! Gzip-only-text/html

Setenvifnocase request_uri/. (GIF | JPG | cab | jpe? G | exe | BMP | MP3 | RAR | zip | SWF | PNG) $ no-gzip dont-vary

</Location>

Deflatecompressionlevel 9

Deflatefilternote input instream

Deflatefilternote output outstream

Deflatefilternote ratio Ratio

# % H host, % t time, % R request URL

Logformat' "% H % L % u % T % R" % {outstream} n/% {instream} n (% {ratio} n %) 'deflate

Customlog logs/deflate_log deflate

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.