PhoenixBakery (phoenix_bakery v1.0.0)
View SourceBetter 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
First thing to do is to add PhoenixBakery
as a dependency.
def deps do
[
{:phoenix_bakery, "~> 0.1.0", runtime: false}
]
end
And configure your Plug.Static
:
plug Plug.Static,
encodings: [{"zstd", ".zst"}],
gzip: true,
brotli: true,
# Rest of the options…
WARNING
Plug 1.12 do not support :encodings
option 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
]