Apache ModBrotli?

504 views
Skip to first unread message

Sharad Binjola

unread,
Feb 17, 2016, 2:21:02 AM2/17/16
to Brotli
It seems to me servers generating dynamic content would need something on the lines of ModDeflate to do brotli compression. Does an Apache (httpd) ModBrotli module already exist or does someone have plans for a project to implement such a module?

Thanks

Evgenii Kliuchnikov

unread,
Feb 17, 2016, 7:51:44 AM2/17/16
to Brotli
Hello.

  Currently only nginx brotli module exists.
  As a temporary solution for Apache you could try this: https://lyncd.com/2015/11/brotli-support-apache/

  We hope that Apache module will appear soon.

Evgenii Kliuchnikov

unread,
Feb 17, 2016, 7:55:16 AM2/17/16
to Brotli
Also there is ongoing brotli integration to pagespeed Apache module.

Sharad Binjola

unread,
Feb 17, 2016, 9:27:53 AM2/17/16
to Brotli
Thanks. Is there a page tracking progress of the pagespeed module so that I can follow along?

Evgenii Kliuchnikov

unread,
Feb 18, 2016, 4:05:23 AM2/18/16
to Brotli

Guillaume Rossolini

unread,
Feb 18, 2016, 10:13:06 AM2/18/16
to Brotli
Hi,

Another way is along these lines (make sure you have mod_negotiation enabled):

conf/mime.types:
application/x-gzip gz gzip
application/x-brotli br bro brotli
application/x-lzma lzma

apache2.conf:
MultiviewsMatch NegotiatedOnly
AddType text/html .br .lzma .gz
AddType text/css .br .lzma .gz
AddType application/javascript .br .lzma .gz
AddEncoding x-gzip .gz
AddEncoding br .br
AddEncoding bro .br
AddEncoding brotli .br
AddEncoding lzma .lzma

sites-available/<your virtualhost>.conf (inside "Directory")
Options +Multiviews

There might be a few other options to consider, but this kind of config seems more flexible.

Regards,

Sharad Binjola

unread,
Feb 18, 2016, 6:00:11 PM2/18/16
to Brotli
Thanks Evgenii - that helps - though it looks like they found some memory utilization issues.

@Guillaume - I am not very well versed with mod_negotiation, but looked at https://httpd.apache.org/docs/2.2/mod/mod_negotiation.html Is the config you have written going to actually do the Brotli encoding of *dynamically generated pages* being flushed out of apache or is it only going to map the given filename extensions to the specified encoding type?

Thanks

Guillaume Rossolini

unread,
Feb 19, 2016, 4:41:05 AM2/19/16
to Brotli
Hi,

brotli compression is very resource-intensive and doing it on the fly might induce too much latency and/or load to be useful.
I'd suggest asynchronously compressing your assets and cached content, not your dynamic content. There is the same problem with zopfli, as both iterate many times to find the best compression ratio, and so they purposefully waste cycles.

By the way, the rules I gave are based on httpd-2.4, they should work on 2.2 too though I have not tried them. They just map filename extensions to specified encoding types.

Regards,

Sharad Binjola

unread,
Feb 19, 2016, 9:31:29 AM2/19/16
to Brotli
Hi Guillaume,

Thanks for the information. Yep, brotli is pretty resource intensive on the server but an nginx module has been developed, so I am going to stay hopeful for apache. My website's traffic runs through some very slow networks where bandwidth is a big issue, so perhaps a moderate quality setting for compression may work well to reduce overall latency, without taxing CPU/memory excessively.

And I agree - Brotli on static files like CSS/JS definitely makes sense.

Thanks.

Reply all
Reply to author
Forward
0 new messages