django-http-compression

This new package provides a middleware for compressing HTTP responses with Zstandard, Brotli, or Gzip. It is like Django’s GZipMiddleware with extra support for modern compression algorithms.

See the announcement post:

6 Likes

Cool, will start using this. Would be nice to have the zstandard part in core at some point.

1 Like

OOoo. Sounds good. I hope, what this middleware has a rich documentation. Then i want to use this too.

1 Like

Hello @adamchainz tks for your contribution. If im using brotli on nginx and whitenoise.storage.CompressedManifestStaticFilesStorage on my django settings.py. Are the results the same as the new middleware?

Checking your site i saw that the new middlware requires python 3.14 and brotli installed at the server.

My scenario uses separate containers to deploy, so only nginx has brotli. I mean the app (django)container dont.

So I came to ask :slight_smile:

hi :waving_hand:

from the blog post:

For Django projects, many deployment situations will let you enable response compression at the web server or CDN level. But there are still cases where you may not have that option or it’s inconvenient, such as with some PaaS providers. In such situations, you can use Django’s built-in GZipMiddleware

so it’s for when you don’t have compression in nginx level