--- id: flask-compress version: "1.24" license: MIT license_treatment: permissive maintenance: active --- # Flask-Compress — Compress responses in your Flask app with gzip, deflate, brotli or zstandard. License: permissive · Maintenance: active · Downloads: 3.9M/mo ## What it is and what it does Flask-Compress is a Flask extension that automatically compresses HTTP responses using the client's preferred algorithm (gzip, deflate, brotli, or zstd). It inspects the Accept-Encoding request header, respects quality factors, and attaches the appropriate Content-Encoding headers while compressing response data. The extension works transparently—once initialized with a Flask app, it compresses eligible MIME types (HTML, CSS, JavaScript, JSON, SVG, fonts, and others) on every request without requiring changes to route handlers. The package supports both global compression and per-view compression via decorators, works with streaming responses, handles ETags for conditional requests, and can integrate with caching layers to serve pre-compressed responses. It's designed as a fallback when a reverse proxy like Nginx cannot handle compression for you, though the documentation notes that server-side compression is the preferred approach. Use it for: - Compress all HTML, CSS, and JavaScript responses in a Flask app to reduce bandwidth without a reverse proxy. - Selectively compress specific views using the @compress.compressed() decorator while leaving others uncompressed. - Serve pre-compressed responses from a cache to reduce CPU load on repeated requests. - Support modern compression algorithms (brotli, zstd) alongside gzip for clients that request them. - Reduce payload size for static files served by Flask when Nginx or similar is not available. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Flask-Compress automatically compresses Flask application responses using gzip, deflate, brotli, or zstd based on client capabilities, reducing bandwidth and improving load times. Yes, if you need HTTP compression in Flask and cannot use a reverse proxy. The package is actively maintained, has low install friction, carries no security vulnerabilities, and uses a permissive MIT license. It supports current Python versions (3.9–3.14) and is straightforward to integrate. Install it when bandwidth reduction or response time matters and you lack infrastructure-level compression. ## Install pip install flask-compress uv add flask-compress poetry add flask-compress ## Installing Flask-Compress Before you install: Low friction install with a pure-Python wheel. Maintenance is active—last commit 2026-08-04, repository not archived. Supports Python 3.9 through 3.14 and PyPy. License in practice: MIT license (permissive). No restrictions on commercial or private use; attribution required but no copyleft obligations. Quickstart: from flask import Flask from flask_compress import Compress app = Flask(__name__) Compress(app) # Or with deferred initialization: compress = Compress() compress.init_app(app) Requires Python 3.9 or newer. brotli and brotlicffi are optional runtime dependencies for Brotli compression; backports.zstd is optional for ZStandard compression. Verify before relying: - Performance impact of compression on CPU vs. bandwidth savings for typical workloads. - Compatibility with async Flask applications or ASGI servers. - Whether brotli and zstd are optional or required for the package to function. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 3.9M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags flask response compression, gzip brotli deflate for flask, http compression middleware, reduce flask response size, flask static file compression, zstd compression flask, content encoding flask, http-compression, flask-extension, middleware [View on SkillFed](https://skillfed.io/packages/flask-compress) · [View on PyPI](https://pypi.org/project/flask-compress/)