Brotli library revival and support for Phoenix 1.6 assets digests

Phoenix 1.6+ will support using additional compressors alongside Zlib one. This one is pretty handy, as it will allow using Brotli and any other compression method that may come in future. To achieve that I needed to revive one library and create another.

Revived library is erl-brotli:

New features include:

  • streaming API for encoding
  • API for decoding
  • almost complete rewrite of the code
  • extensive testing, together with property tests

I have contacted autor of that library whether they are willing to pass the Hex repository to me as I would prefer to not need create additional name for it. I haven’t heard anything back yet.

Second library is Phoenix.Digester.Compressor implementation that can use above library, however do not require it, and will gracefully fallback to CLI utility:

Again, not on Hex yet, as I need to have above library handled first.

This will allow user to just add this line in config/config.exs:

config :phoenix,
  static_compressors: [Phoenix.Digester.Gzip, PhoenixBrotliCompressor]

Together with adding:

plug Plug.Static,
  brotli: true,
  # …

In their endpoint and now be happy user of the better compression thanks to Brotli.

19 Likes

This library became deprecated in favour of phoenix_bakery which provides the same features + better GZIP and Zstandard

9 Likes

I love it, thanks @hauleth.