Server-sent-event (text/event-stream) responses bypass compression and the response cache entirely, stream chunk-by-chunk with a timeout-free client, and account bytes and errors mid-stream.
Detection happens twice: on the request ("stream": true selects the timeout-free client) and on the response (Content-Type selects the passthrough branch).
SSE detection & passthrough
SSE DETECTION & PASSTHROUGH
Why compression is skipped for SSE
WHY COMPRESSION IS SKIPPED FOR SSE
Byte accounting: only response_body_bytes accumulates during the stream (via the .inspect closure); tokens_saved is not touched because nothing was compressed.
sse_stream_errors surfaces in /stats and /metrics (aphrodite_sse_stream_errors_total).