Changes between Initial Version and Version 1 of Ticket #36655
- Timestamp:
- Oct 10, 2025, 11:10:54 AM (11 hours ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #36655
- Property Summary GzipMiddleware buffers streaming responses → GZipMiddleware buffers streaming responses
-
Ticket #36655 – Description
initial v1 1 Currently, `G zipMiddleware`, via `compress_sequence()`, buffers the entire response before sending it to the client. This can cause issues for clients that expect to receive data in chunks, such as those using Server-Sent Events (SSE) or WebSockets.1 Currently, `GZipMiddleware`, via `compress_sequence()`, buffers the entire response before sending it to the client. This can cause issues for clients that expect to receive data in chunks, such as those using Server-Sent Events (SSE) or WebSockets. 2 2 3 3 This issue was reported to me in the django-browser-reload project back in [https://github.com/adamchainz/django-browser-reload/pull/161 Issue #161 (2023)], where a contributor fixed it with a workaround, and I didn't think to investigate. Now, while implementing [https://github.com/adamchainz/django-http-compression django-http-compression], I have realized that it’s a proper bug that can be fixed by adding a call to `zfile.flush()`, as done in its [https://github.com/adamchainz/django-http-compression/pull/8 PR #8]. 4 4 5 To reproduce the issue, use the below app, which can be run with `uv run --script`. If you comment out `GzipMiddleware` and load the page in a browser, you will see the numbers incrementing every second. If you include `GzipMiddleware`, the page will never load. Adding the `zfile.flush()` call in `compress_sequence()` fixes the issue.5 To reproduce the issue, use the app below, which can be run with `uv run --script`. If you comment out `GzipMiddleware` and load the page in a browser, you will see the numbers incrementing every second. If you include `GzipMiddleware`, the page will never load. Adding the `zfile.flush()` call in `compress_sequence()` fixes the issue. 6 6 7 7 {{{#!python