I couldn't see a way to compress responses and accept compressed requests automatically so I wrote this:
https://gist.github.com/lukestanley/a6cb1daffd2f0ed9829b6b96e067d8cf
I haven't profiled it but it seems to work well for my purposes.
However it doesn't compress static files when requested, as they have an empty response body.
your gist works for me, the response has an empty body when its returning a 304 (i.e. the client already has the resource). Try clearing your cache while testing ctrl+shift+r in chrome
I'm a fan. Maybe rewrite it as an extension and include it in the extensions documentation?
I had this extension on the backburner for a while, just published it: sanic_compress for gzipping responses.
It's basically a port of Flask-Compress.
Closing for #463
Brotli — annother choice
Thanks for pointing out the 304 status @abuckenheimer. You are welcome to do whatever with the example gist.
Most helpful comment
I'm a fan. Maybe rewrite it as an extension and include it in the extensions documentation?