$ the-wire · showcase
Open WebUI slashes per-request and per-model overhead
By RepoJournal · Filed · About Open WebUI
Open WebUI cut redundant work across ASGI middleware, ORM session calls, and model listing paths, with the largest win coming from caching static security headers entirely.
Open WebUI eliminated per-response recomputation in ASGI middleware [1]. SecurityHeadersMiddleware now computes its header list once at construction instead of on every response, and skips wrapping send entirely when no security env vars are set. RedirectMiddleware no longer decodes and parse_qs's every GET query string, only those it acts on. The combined effect removes 14 os.environ.get lookups plus regex validation per response, in addition to the query parsing overhead on all GET requests.
A second performance thread targets the model layer [2]. Both session factories run with expire_on_commit=False, so fifty session.refresh calls after commit were issuing re-SELECTs of chat JSON blobs and user settings that the session already held, purely to overwrite identical data. Those calls are dropped across nearly every write path. Related work in model list assembly [3] removes per-model costs from get_all_models: active action and filter id sets now come from a column-only query instead of loading full function rows with plugin source, and tools deferral was fixed so tools listings actually omit the content column instead of loading full Python source [4]. Five caller sites pass defer_content=True expecting this optimization, and the new query selects every column except content.
A separate chore removes the unused ArchivedChatsModal component [5], which is a small cleanup with no user-facing effect.
Action items
- → Benchmark request latency and model listing endpoints after pulling the latest dev build open-webui/open-webui [monitor]
References
- [1] perf: stop recomputing static work in per-response ASGI middlewares (#27229) ↗ open-webui/open-webui
- [2] perf: drop redundant session.refresh calls after commit across the model layer (#27381) ↗ open-webui/open-webui
- [3] perf: cut repeated per-model work out of model list assembly ↗ open-webui/open-webui
- [4] perf: make tools defer_content real and batch tool and knowledge access filters (#27387) ↗ open-webui/open-webui
- [5] chore: remove unused ArchivedChatsModal component ↗ open-webui/open-webui