[PR #14307] [CLOSED] perf: Add GZip, Brotli, ZStd compression middleware that respects User Accept-Encoding header #46485

Closed
opened 2026-04-29 21:19:06 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/14307
Author: @jtbaker
Created: 5/25/2025
Status: ❌ Closed

Base: dev ← Head: add-compression


📝 Commits (5)

  • 2ca220b add starlette compress dependency
  • c53a312 add compression middleware to initialization pipeline
  • 5f0a750 lock modification after uv sync
  • 0097cc7 whitespace
  • f1ab0de alphabetical

📊 Changes

3 files changed (+682 additions, -882 deletions)

View changed files

📝 backend/open_webui/main.py (+2 -0)
📝 pyproject.toml (+1 -29)
📝 uv.lock (+679 -853)

📄 Description

Pull Request Checklist

Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.

Before submitting, make sure you've checked the following:

  • Target branch: Please verify that the pull request targets the dev branch.
  • Description: Provide a concise description of the changes made in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Have you written and run sufficient tests to validate the changes?
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
  • Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:
    • BREAKING CHANGE: Significant changes that may affect compatibility
    • build: Changes that affect the build system or external dependencies
    • ci: Changes to our continuous integration processes or workflows
    • chore: Refactor, cleanup, or other non-functional code changes
    • docs: Documentation update or addition
    • feat: Introduces a new feature or enhancement to the codebase
    • fix: Bug fix or error correction
    • i18n: Internationalization or localization changes
    • perf: Performance improvement
    • refactor: Code restructuring for better maintainability, readability, or scalability
    • style: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.)
    • test: Adding missing tests or correcting existing tests
    • WIP: Work in progress, a temporary label for incomplete or ongoing work

Description

This PR adds a Starelette based Compression middleware (https://github.com/Zaczero/starlette-compress) that compresses responses based on the user's Accept-Encoding headers from their browser, with the goal of greatly reducing the bandwidth and time needed to transfer both static assets, as well as JSON responses to AJAX requests (models, configurations, message history, etc.). In my testing, it reduces the bandwidth of most compressible HTTP responses greatly - seeing 1/3 the amount of data sent over the wire, with the largest asset I saw, the font TTF file being reduces from ~650Kb to ~250Kb when sent using ZStd.

Screenshot 2025-05-24 at 11 21 30 PM
Screenshot 2025-05-24 at 11 41 37 PM

Added

  • Added compression (GZip, Brotli, ZStd - dynamic based on user's Accept-Encoding headers).

Changed

  • N/A

Deprecated

  • N/A

Removed

  • N/A

Fixed

Security

Breaking Changes

  • N/A

Additional Information

  • [Insert any additional context, notes, or explanations for the changes]
    • [Reference any related issues, commits, or other relevant information]

Screenshots or Videos

  • [Attach any relevant screenshots or videos demonstrating the changes]

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/14307 **Author:** [@jtbaker](https://github.com/jtbaker) **Created:** 5/25/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `add-compression` --- ### 📝 Commits (5) - [`2ca220b`](https://github.com/open-webui/open-webui/commit/2ca220ba82fbe03591761a11fd35864cba3461f6) add starlette compress dependency - [`c53a312`](https://github.com/open-webui/open-webui/commit/c53a3125be2a904d2fa398fc864183f7a9325be1) add compression middleware to initialization pipeline - [`5f0a750`](https://github.com/open-webui/open-webui/commit/5f0a7509ba11e360014cc2eae28a3079987c2725) lock modification after uv sync - [`0097cc7`](https://github.com/open-webui/open-webui/commit/0097cc77ab205deeaaaf83513bb9907a3854e5ef) whitespace - [`f1ab0de`](https://github.com/open-webui/open-webui/commit/f1ab0def992fc0e7bf2ca8f7475be97c13765bcd) alphabetical ### 📊 Changes **3 files changed** (+682 additions, -882 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/main.py` (+2 -0) 📝 `pyproject.toml` (+1 -29) 📝 `uv.lock` (+679 -853) </details> ### 📄 Description # Pull Request Checklist ### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/discussions) and describe your changes before submitting a pull request. **Before submitting, make sure you've checked the following:** - [x] **Target branch:** Please verify that the pull request targets the `dev` branch. - [x] **Description:** Provide a concise description of the changes made in this pull request. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [ ] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources? - [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [ ] **Testing:** Have you written and run sufficient tests to validate the changes? - [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? - [x] **Prefix:** To clearly categorize this pull request, prefix the pull request title using one of the following: - **BREAKING CHANGE**: Significant changes that may affect compatibility - **build**: Changes that affect the build system or external dependencies - **ci**: Changes to our continuous integration processes or workflows - **chore**: Refactor, cleanup, or other non-functional code changes - **docs**: Documentation update or addition - **feat**: Introduces a new feature or enhancement to the codebase - **fix**: Bug fix or error correction - **i18n**: Internationalization or localization changes - **perf**: Performance improvement - **refactor**: Code restructuring for better maintainability, readability, or scalability - **style**: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.) - **test**: Adding missing tests or correcting existing tests - **WIP**: Work in progress, a temporary label for incomplete or ongoing work ### Description This PR adds a Starelette based Compression middleware (https://github.com/Zaczero/starlette-compress) that compresses responses based on the user's `Accept-Encoding` headers from their browser, with the goal of greatly reducing the bandwidth and time needed to transfer both static assets, as well as JSON responses to AJAX requests (models, configurations, message history, etc.). In my testing, it reduces the bandwidth of most compressible HTTP responses greatly - seeing 1/3 the amount of data sent over the wire, with the largest asset I saw, the font TTF file being reduces from ~650Kb to ~250Kb when sent using ZStd. ![Screenshot 2025-05-24 at 11 21 30 PM](https://github.com/user-attachments/assets/18324404-13e1-41aa-9441-346242c34b1a) ![Screenshot 2025-05-24 at 11 41 37 PM](https://github.com/user-attachments/assets/12aecd8d-d834-4910-b4ee-ad218b44a6e1) ### Added - Added compression (GZip, Brotli, ZStd - dynamic based on user's `Accept-Encoding` headers). ### Changed - N/A ### Deprecated - N/A ### Removed - N/A ### Fixed - https://github.com/open-webui/open-webui/discussions/13787 - https://github.com/open-webui/open-webui/discussions/12986 ### Security - Added new dependency of https://github.com/Zaczero/starlette-compress ### Breaking Changes - N/A --- ### Additional Information - [Insert any additional context, notes, or explanations for the changes] - [Reference any related issues, commits, or other relevant information] ### Screenshots or Videos - [Attach any relevant screenshots or videos demonstrating the changes] ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-29 21:19:06 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#46485