{"id":13708399,"url":"https://github.com/friedelwolff/django-compression-middleware","last_synced_at":"2026-04-01T20:44:06.579Z","repository":{"id":57419466,"uuid":"167521556","full_name":"friedelwolff/django-compression-middleware","owner":"friedelwolff","description":"Django middleware to compress responses using several algorithms.","archived":false,"fork":false,"pushed_at":"2024-08-27T14:54:53.000Z","size":80,"stargazers_count":47,"open_issues_count":8,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-15T11:10:36.602Z","etag":null,"topics":["brotli","content-encoding","django","gzip","middleware","zstandard","zstd"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/friedelwolff.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-25T09:29:41.000Z","updated_at":"2025-07-31T18:39:51.000Z","dependencies_parsed_at":"2024-05-12T22:35:19.673Z","dependency_job_id":"b8f6cec0-4fdf-4ef5-95ef-4c85871958f1","html_url":"https://github.com/friedelwolff/django-compression-middleware","commit_stats":{"total_commits":60,"total_committers":2,"mean_commits":30.0,"dds":0.01666666666666672,"last_synced_commit":"708e2505b427f682fe1edc88c360f13219821590"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/friedelwolff/django-compression-middleware","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friedelwolff%2Fdjango-compression-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friedelwolff%2Fdjango-compression-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friedelwolff%2Fdjango-compression-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friedelwolff%2Fdjango-compression-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/friedelwolff","download_url":"https://codeload.github.com/friedelwolff/django-compression-middleware/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/friedelwolff%2Fdjango-compression-middleware/sbom","scorecard":{"id":411495,"data":{"date":"2025-08-11","repo":{"name":"github.com/friedelwolff/django-compression-middleware","commit":"7b5306805b38cfb1be1cd406c8514493b11c14e3"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.5,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/main.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 2/23 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/friedelwolff/django-compression-middleware/main.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/friedelwolff/django-compression-middleware/main.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/main.yml:35","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Mozilla Public License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 10 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"19 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2018-6 / GHSA-2f9x-5v75-3qv4","Warn: Project is vulnerable to: PYSEC-2019-17 / GHSA-337x-4q8g-prc5","Warn: Project is vulnerable to: PYSEC-2020-36 / GHSA-3gh2-xw74-jmcw","Warn: Project is vulnerable to: PYSEC-2018-2 / GHSA-5hg3-6c2f-f3wr","Warn: Project is vulnerable to: PYSEC-2021-98 / GHSA-68w8-qjq3-2gfm","Warn: Project is vulnerable to: PYSEC-2019-10 / GHSA-6c7v-2f49-8h26","Warn: Project is vulnerable to: PYSEC-2019-13 / GHSA-6r97-cj55-9hrq","Warn: Project is vulnerable to: PYSEC-2019-79 / GHSA-7rp2-fm2h-wchj","Warn: Project is vulnerable to: GHSA-7xr5-9hcq-chf9","Warn: Project is vulnerable to: GHSA-8x94-hmjh-97hq","Warn: Project is vulnerable to: PYSEC-2017-44 / GHSA-9r8w-6x8c-6jr9","Warn: Project is vulnerable to: PYSEC-2019-11 / GHSA-c4qh-4vgv-qc6g","Warn: Project is vulnerable to: PYSEC-2019-12 / GHSA-h5jv-4p7w-64jg","Warn: Project is vulnerable to: PYSEC-2020-35 / GHSA-hmr4-m2h5-33qx","Warn: Project is vulnerable to: PYSEC-2018-5 / GHSA-r28v-mw67-m5p9","Warn: Project is vulnerable to: GHSA-rrqc-c2jx-6jgv","Warn: Project is vulnerable to: PYSEC-2019-14 / GHSA-v9qg-3j8p-r63v","Warn: Project is vulnerable to: PYSEC-2019-16 / GHSA-vfq6-hq5r-27r6","Warn: Project is vulnerable to: PYSEC-2019-18 / GHSA-wh4h-v3f2-r2pp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T22:48:51.305Z","repository_id":57419466,"created_at":"2025-08-18T22:48:51.305Z","updated_at":"2025-08-18T22:48:51.305Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31291781,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["brotli","content-encoding","django","gzip","middleware","zstandard","zstd"],"created_at":"2024-08-02T23:00:21.885Z","updated_at":"2026-04-01T20:44:06.549Z","avatar_url":"https://github.com/friedelwolff.png","language":"Python","funding_links":[],"categories":["Serialization"],"sub_categories":["Tools"],"readme":"===========================================================================\nDjango Compression Middleware\n===========================================================================\n\n\nThis middleware implements compressed content encoding for HTTP. It is similar\nto Django's ``GZipMiddleware`` (`documentation`_), but additionally supports\nother compression methods. It is meant to be a drop-in replacement for Django's\n``GZipMiddleware``. Its documentation — including security warnings — therefore\napply here as well.\n\nThe middleware is focussed on the task of compressing typical Django responses\nsuch as HTML, JSON, etc.  Both normal (bulk) and streaming responses are\nsupported. For static file compression, have a look at other projects such as\n`WhiteNoise`_.\n\nZstandard is a new method for compression with little client support so far.\nMost browsers now support Brotli compression (check support status on `Can I\nuse... Brotli`_). The middleware will choose the best compression method\nsupported by the client as indicated in the request's ``Accept-Encoding``\nheader. In order of preference:\n\n- Zstandard (zstd)\n- Brotli (br)\n- gzip (gzip)\n\nSummary of the project status:\n\n* .. image:: https://img.shields.io/github/actions/workflow/status/friedelwolff/django-compression-middleware/main.yml\n     :target: https://github.com/friedelwolff/django-compression-middleware/actions\n* .. image:: https://img.shields.io/pypi/djversions/django-compression-middleware.svg\n* .. image:: https://img.shields.io/pypi/pyversions/django-compression-middleware.svg\n* .. image:: https://img.shields.io/pypi/implementation/django-compression-middleware.svg\n\n.. _`documentation`: https://docs.djangoproject.com/en/dev/ref/middleware/#module-django.middleware.gzip\n.. _`WhiteNoise`: https://whitenoise.readthedocs.io/\n.. _`Can I use... Brotli`: http://caniuse.com/#search=brotli\n\nInstallation and usage\n----------------------\n\nThe following requirements are supported and tested in all reasonable\ncombinations:\n\n- Python versions: 3.6–3.12\n- Interpreters: CPython and PyPy.\n- Django versions: 1.11–5.0\n\n.. code:: shell\n\n    pip install --upgrade django-compression-middleware\n\nTo apply compression to all the views served by Django, add\n``compression_middleware.middleware.CompressionMiddleware`` to the\n``MIDDLEWARE`` setting:\n\n.. code:: python\n\n    MIDDLEWARE = [\n        # ...\n        'compression_middleware.middleware.CompressionMiddleware',\n        # ...\n    ]\n\nRemove ``GZipMiddleware`` and ``BrotliMiddleware`` if you used it before.\nConsult the Django documentation on the correct `ordering of middleware`_.\n\n.. _`ordering of middleware`: https://docs.djangoproject.com/en/dev/ref/middleware/#middleware-ordering\n\nAlternatively you can decorate views individually to serve them with\ncompression:\n\n.. code:: python\n\n    from compression_middleware.decorators import compress_page\n\n    @compress_page\n    def index_view(request):\n        ...\n\nNote that your browser might not send the ``br`` entry in the ``Accept-Encoding``\nheader when you test without HTTPS (common on localhost). You can force it to\nsend the header, though. In Firefox, visit ``about:config`` and set\n``network.http.accept-encoding`` to indicate support. Note that you might\nencounter some problems on the web with such a setting (which is why Brotli is\nonly supported on secure connections by default).\n\nCredits and Resources\n---------------------\n\nThe code and tests in this project are based on Django's ``GZipMiddleware`` and\nVašek Dohnal's ``django-brotli``. For compression, it uses the following modules\nto bind to fast C modules:\n\n- The `zstandard`_ bindings. It supports both a C module (for CPython) and CFFI\n  which should be appropriate for PyPy. See the documentation for full details.\n- The `Brotli`_ bindings or `brotlipy`_. The latter is preferred on PyPy since\n  it is implemented using cffi. But both should work on both Python\n  implementations.\n- Python's builtin `gzip`_ module.\n\n.. _zstandard: https://pypi.org/project/zstandard/\n.. _Brotli: https://pypi.org/project/Brotli/\n.. _brotlipy: https://pypi.org/project/brotlipy/\n.. _gzip: https://docs.python.org/3/library/gzip.html\n\nFurther readding on Wikipedia:\n\n- `HTTP compression \u003chttps://en.wikipedia.org/wiki/HTTP_compression\u003e`__\n- `Zstandard \u003chttp://www.zstd.net/\u003e`__\n- `Brotli \u003chttps://en.wikipedia.org/wiki/Brotli\u003e`__\n- `gzip \u003chttps://en.wikipedia.org/wiki/Gzip\u003e`__\n\nContributing\n------------\n\n1. Clone this repository (``git clone ...``)\n2. Create a virtualenv\n3. Install package dependencies: ``pip install --upgrade -r requirements_dev.txt``\n4. Change some code\n5. Run the tests: in the project root simply execute ``pytest``, and afterwards\n   preferably ``tox`` to test the full test matrix. Consider installing as many\n   supported interpreters as possible (having them in your ``PATH`` is often\n   sufficient).\n6. Submit a pull request and check for any errors reported by the Continuous\n   Integration service.\n\nLicense\n-------\n\nThe MPL 2.0 License\n\nCopyright (c) 2019-2024 `Friedel Wolff \u003chttps://fwolff.net.za/\u003e`_.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriedelwolff%2Fdjango-compression-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffriedelwolff%2Fdjango-compression-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffriedelwolff%2Fdjango-compression-middleware/lists"}