NOTE: Please use the official module since Apache 2.4.26 : Apache Module mod_brotli
mod_brotli is a Brotli compression module for Apache HTTPD Server.
-
Libtool
-
Automake
git clone --depth=1 --recursive https://github.com/kjdev/apache-mod-brotli.git
cd apache-mod-brotli
./autogen.sh
./configure
make
install -p -m 755 -D .libs/mod_brotli.so /etc/httpd/modules/mod_brotli.so
httpd.conf
:
# Load module
LoadModule brotli_module modules/mod_brotli.so
<IfModule brotli_module>
# Output filter
AddOutputFilterByType BROTLI text/html text/plain text/css text/xml
# SetOutputFilter BROTLI
# SetEnvIfNoCase Request_URI \.txt$ no-br
# Compression
## BrotliCompressionLevel: 0-11 (default: 11)
BrotliCompressionLevel 10
## BrotliWindowSize: 10-24 (default: 22)
BrotliWindowSize 22
# Specifies how to change the ETag header when the response is compressed
## BrotliAlterEtag: AddSuffix, NoChange, Remove (default: AddSuffix)
BrotliAlterEtag AddSuffix
# Filter note
BrotliFilterNote Input brotli_in
BrotliFilterNote Output brotli_out
BrotliFilterNote Ratio brotli_ratio
LogFormat '"%r" %{brotli_out}n/%{brotli_in}n (%{brotli_ratio}n)' brotli
CustomLog logs/access_log brotli
</IfModule>