Skip to content

Django middleware that compresses response using brotli algorithm.

License

Notifications You must be signed in to change notification settings

illagrenan/django-brotli

Repository files navigation

Django Brotli: Middleware that compresses response using brotli algorithm

License: MIT pypi pypi Python version Supported Django
Build Status codecov

Introduction

This project consists of BrotliMiddleware which works the same as Django GZipMiddleware (Docs/Source). BrotliMiddleware will compress content of HTTP response using brotli algorithm (Brotli Compressed Data Format is defined in RFC 7932).

In November 2016 is brotli supported by Firefox, Chrome, Android Browser and Opera (detailed stats on caniuse). Brotli is applied only when client has sent Accept-Encoding header containing br.

Installation

  • Supported Python versions are: ">=3.10, <3.14".
  • Supported Django versions are: >=4,<6.
poetry add django-brotli@latest

or

pip install --upgrade django-brotli

Add django_brotli.middleware.BrotliMiddleware to MIDDLEWARE:

MIDDLEWARE = [
    'django_brotli.middleware.BrotliMiddleware',
    # ...
]

Credits and Resources

Contributing

  1. Clone this repository (git clone ...)
  2. Install package dependencies: poetry install --with dev -v
  3. Change some code
  4. Run tests: in project root simply execute pytest
  5. Submit PR :)

License

The MIT License (MIT)