Django compression middleware now supports Zstandard

I think I first learnt about Zstandard (zstd) in a blog post by Gregory Szorc. At some stage I saw that zstd is also registered with IANA’s content coding registry for HTTP and I tried to find out how much of the web ecosystem already supported it. At that time there was a patch for zstd support in Nginx, but nothing else, as I recall.

Things are not much better right now, but zstd continued maturing and has been adopted for non-web use by many projects. I recently checked and found one HTTP client, wget2, that claimed support for zstd. So I decided to add support for zstd to Django compression middleware and to test it with wget2. With wget2 I can be sure that at least one web client is able to consume what the middleware provides.

I released version 0.3.0 of Django compression middleware a few days ago with support for zstd. Since I don’t know of any browsers that support it yet, I don’t expect many people to be excited about this. There isn’t even information on the Can I use … website about zstd yet (github issue). However, I see this as my small contribution to the ecosystem.

It is not clear that Zstandard will provide a massive win over the alternatives in all cases, but my testing on multiple HTML and JSON files suggest that it is mostly equal to or better than Brotli and basically always better than gzip with the defaults I currently use. “Better” here means a smaller payload produced in the same or less time.

Django compression middleware now supports zstd, Brotli and gzip.