--- id: brotli-asgi version: "1.6.0" license: MIT license_treatment: permissive maintenance: aging --- # brotli-asgi — A compression AGSI middleware using brotli License: permissive · Maintenance: aging · Downloads: 678.0K/mo ## What it is and what it does BrotliMiddleware is an ASGI middleware that automatically compresses HTTP responses using Brotli encoding. It integrates directly into Starlette and other ASGI frameworks, intercepting responses and applying compression before they reach the client. The middleware respects Accept-Encoding headers and can fall back to gzip for clients that don't support Brotli. You configure it by adding it to your application's middleware stack, optionally tuning compression quality (0–11), mode (generic, text, or font), window size, block size, and minimum response size threshold. It skips responses that already have Content-Encoding set to avoid double-encoding, and it's designed as a direct replacement for the GZipMiddleware shipped with Starlette. Use it for: - Reduce bandwidth for JSON APIs and web services by compressing responses with Brotli instead of gzip - Serve static HTML and text content over the web with better compression density than gzip - Add compression to ASGI applications without writing custom middleware - Optimize WOFF 2.0 font delivery using Brotli's font-specific compression mode - Maintain gzip compatibility for older clients while preferring Brotli for modern browsers ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. BrotliMiddleware adds Brotli compression to ASGI applications as a drop-in replacement for GZipMiddleware, offering denser compression with configurable quality and fallback to gzip when needed. Yes, if you're running an ASGI framework and want better compression than gzip. The package is lightweight, has no security vulnerabilities, and supports Python 3.9–3.14. Maintenance is aging but stable; the last release was 224 days ago and the repository remains active. Install it if bandwidth reduction matters for your workload and your clients support Brotli. ## Install pip install brotli-asgi uv add brotli-asgi poetry add brotli-asgi ## Installing brotli-asgi Before you install: Installs cleanly with only two runtime dependencies (starlette and brotli). Maintenance is aging—last release was 224 days ago—but the repository remains active and unarchived with a recent commit on 2026-01-02. License in practice: MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects. Quickstart: pip install brotli-asgi from brotli_asgi import BrotliMiddleware from starlette.applications import Starlette from starlette.middleware import Middleware app = Starlette(middleware=[Middleware(BrotliMiddleware)]) Verify before relying: - Performance gains over gzip in production workloads with typical response sizes and quality settings - Browser compatibility breakdown for older clients not supporting Brotli - CPU overhead during compression relative to gzip at different quality levels ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 678.0K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags brotli compression middleware asgi, response compression middleware, brotli gzip alternative, asgi compression middleware, http response compression, brotli encoding asgi, web compression middleware, compression, middleware, performance [View on SkillFed](https://skillfed.io/packages/brotli-asgi) · [View on PyPI](https://pypi.org/project/brotli-asgi/)