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.
You can configure gzip compression for the responses from a particular endpoint.
config :app_name, AppName.Endpoint,
http: [compress: true]
As answered by Endersstocke setting http: [compress: true]
in the endpoint config works, even for websockets. However there are some limitations:
Phoenix in its current version (1.3.0) or more specific: cowboy (1.1) only supports x-webkit-deflate-frame
compression for websockets. From my tests I've seen that only Safari sends these requests header meaning on Chrome you will not experience any compression at all.
So if you want to have the permessage-deflate
compression you will have to wait until Cowboy 2.0. See docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With