Enabling Brotli compression on Apache

CentOS Web Panel is deployed in > /etc/ld.so.conf ldconfig

Compile Apache with this flags from CWP Apache rebuild module :


After Apache is rebuilded add this configs and create the config file :

touch /usr/local/apache/conf.d/brotli.conf

Now add this line to /usr/local/apache/conf.d/brotli.conf :

LoadModule brotli_module modules/mod_brotli.so

BrotliCompressionQuality 6

BrotliFilterNote Input brotli_input_info
BrotliFilterNote Output brotli_output_info
BrotliFilterNote Ratio brotli_ratio_info
LogFormat '"%r" %{brotli_output_info}n/%{brotli_input_info}n (%{brotli_ratio_info}n%%)' brotli
CustomLog "logs/brotli_log" brotli

#Don't compress content which is already compressed
SetEnvIfNoCase Request_URI 
.(gif|jpe?g|png|swf|woff|woff2) no-brotli dont-vary

#Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary

After configuration restart Apache webserver :

service httpd restart

To enable brotli compression for your site add config to .htaccess :

AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/x-javascript application/javascript application/json application/x-font-ttf application/vnd.ms-fontobject image/x-icon


CentOS Web Panel is deployed in About 15 hours ago

  • How to protect your PERSONAL DATA with ZERO knowledge readyspace.com/how-to-protect-…

  • Contact Us