Phoenix enable GZIP compression
In lib/myapp_web/endpoint.ex
change [[GZIP]] from false
to true
:
plug(Plug.Static, at: "/", from: :tilex, gzip: true, only: ~w(assets ...))
But why stop there? We can [[compress]] our dynamic document bodies just as easily. In config/prod.exs
, add compress: true
to the [[HTTP]] config of the [[endpoint]].
config :my_app, MyAppWeb.Endpoint,
http: [port: {:system, "PORT"}, compress: true]
Once done, you can validate that there is a content-encoding: gzip
[[HTTP headers]] in the [[HTTP Response]].