{"id":22408,"library":"starlette-cramjam","title":"Starlette Cramjam","description":"Middleware that adds compression (gzip, brotli, zstd, deflate) to Starlette ASGI applications using the cramjam library. Version 0.7.0; releases are irregular.","status":"active","version":"0.7.0","language":"python","source_language":"en","source_url":"https://github.com/developmentseed/starlette-cramjam","tags":["starlette","compression","middleware","gzip","brotli","zstd","cramjam"],"install":[{"cmd":"pip install starlette-cramjam","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for ASGI middleware and request/response handling.","package":"starlette","optional":false},{"reason":"Compression/decompression backend for gzip, brotli, zstd, deflate.","package":"cramjam","optional":false}],"imports":[{"note":"CompressMiddleware is not exported from __init__.py; must import from .middleware submodule.","wrong":"from starlette_cramjam import CompressMiddleware","symbol":"CompressMiddleware","correct":"from starlette_cramjam.middleware import CompressMiddleware"}],"quickstart":{"code":"from starlette.applications import Starlette\nfrom starlette.responses import PlainTextResponse\nfrom starlette.routing import Route\nfrom starlette_cramjam.middleware import CompressMiddleware\n\nasync def hello(request):\n    return PlainTextResponse(\"Hello, World!\")\n\napp = Starlette(routes=[Route('/', hello)])\napp.add_middleware(CompressMiddleware)","lang":"python","description":"Basic Starlette app with compression middleware enabled."},"warnings":[{"fix":"Upgrade Python to 3.11+ or pin to starlette-cramjam <0.6.0.","message":"Python 3.9 and 3.10 support dropped in version 0.6.0; requires Python >=3.11.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Set min_size=0 in CompressMiddleware(min_size=0) to compress all responses.","message":"The middleware may skip compression for small responses based on default minimum size (min_size). Responses smaller than 500 bytes are not compressed.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use: from starlette_cramjam.middleware import CompressMiddleware","cause":"The class is in the .middleware submodule, not in __init__.py.","error":"ImportError: cannot import name 'CompressMiddleware' from 'starlette_cramjam'"},{"fix":"If you must compress 204, downgrade to <0.7.0 or modify middleware source.","cause":"Version 0.7.0 intentionally skips compression for 204 responses to avoid breaking RFC 7231.","error":"Compression not applied to 204 No Content responses"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}