Search code examples
elixirphoenix-framework

How do I enable compression on channels in Phoenix?


I've got a channel in phoenix that pushes out ~4KB of data, a lot of it highly repeating and was wondering if there was a way to turn on compression for that channel.

It looks fairly simple to do if I was working with a phoenix controller, but I haven't been able to find out if this is possible or documented somewhere for a channel.

Thanks a bunch.


Solution

  • You can configure gzip compression for the responses from a particular endpoint.

    config :app_name, AppName.Endpoint,
      http: [compress: true]