View Source PhoenixBakery (phoenix_bakery v0.1.2)
Better compression for your Phoenix assets.
This is set of modules that implement Phoenix.Digester.Compressor
behaviour which can be used together with Phoenix 1.6 or later for better
compression of the static assets served by Plug.Static.
installation
Installation
First thing to do is to add PhoenixBakery as a dependency.
def deps do
[
{:phoenix_bakery, "~> 0.1.0", runtime: false}
]
endAnd configure your Plug.Static:
plug Plug.Static,
encodings: [{"zstd", ".zstd"}],
gzip: true,
brotli: true,
# Rest of the options…WARNING
Plug 1.12 do not support
:encodingsoption and this option is ignored. So Zstandard-compressed files will not be served to the clients, even if client will have support for such format.
Then you need to configure your compressors via Phoenix configuration:
config :phoenix,
static_compressors: [
# Pick all that you want to use
PhoenixBakery.Gzip,
PhoenixBakery.Brotli,
PhoenixBakery.Zstd
]