mod_brotli sample configuration

Started by Gregg, June 17, 2017, 06:05:55 AM

Previous topic - Next topic

Gregg

Thanks to Evgeny Kotkov of Apache's Subversion Project, Apache 2.4.26 has a new inline compression module (mod_brotli) using Google's new Brotli compression library. We did not include any configuration sample for it so I'm posting one here.

This configuration uses brotli compression for browsers that have it (ltest Chrome and Firefox) and falls back to gzip (deflate) for browsers that don't and is the minimum to make it work. There are other options for both mod_brotli and mod_deflate for logging, compression quality, window, block size and others on it's documentation page, very similar to mod_deflate.

bro.exe has also been included with our distribution which is a command line application that will compress/uncompress files. This could be used to serve Brotli pre-compressed content for speed and lessen CPU usage when serving files.

<IfModule !brotli_module>
    LoadModule brotli_module modules/mod_brotli.so
</IfModule>
<IfModule !deflate_module>
    LoadModule deflate_module modules/mod_deflate.so
</IfModule>

# mod_filter needed for AddOutputFilterByType
<IfModule !filter_module>
    LoadModule filter_module modules/mod_filter.so
</IfModule>

AddOutputFilterByType BROTLI_COMPRESS;DEFLATE text/html text/plain text/css text/xml

# See http://httpd.apache.org/docs/2.4/mod/mod_brotli.html
# for available mod_brotli directives

# See http://httpd.apache.org/docs/2.4/mod/mod_deflate.html
# for available mod_deflate directives


puertoblack2003

this config ? do it goes with http or vhost files?

Gregg

If you want it global (for all vhost) put it in httpd.conf. If you only want it used on certain sites, inside their vhosts configs. Might as well just go global with it.

Drupal uses pre-compressed css files and other webapps might as well, you wouldn't want it compressing those (double compressed) which a browser would never figure out.

That said, you configure globally, configuring it differently in a vhost will override global, htaccess will override it again. see http://httpd.apache.org/docs/2.4/configuring.html#scope

sorry for the late reply

puertoblack2003

thanks for the info.I'll give that suggestion a go.