Document that streaming responses are already excluded from compression

Clarified in code comments and documentation that:
- Streaming responses (ReadableStream bodies) are rejected from StaticRoute
- They throw error at StaticRoute.fromJS():160 requiring buffered body
- Streams go through RequestContext, not StaticRoute
- Compression only applies to fully buffered static Response objects

This answers the "how does streaming work" question - it doesn't go through
StaticRoute at all, so compression is never applied to streams. No special
handling needed - the architecture naturally prevents it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude Bot
2025-11-07 11:16:54 +00:00
parent 570d3a394a
commit 05bf4baf2b
2 changed files with 8 additions and 5 deletions

View File

@@ -249,6 +249,9 @@ pub fn onRequest(this: *StaticRoute, req: *uws.Request, resp: AnyResponse) void
}
/// Try to serve a compressed variant if compression is enabled and conditions are met
///
/// NOTE: Streaming responses are NOT handled here - they're rejected at fromJS() line 160
/// and go through RequestContext instead. This only compresses fully buffered static responses.
fn tryServeCompressed(this: *StaticRoute, req: *uws.Request, resp: AnyResponse) bool {
const server = this.server orelse return false;
const config = server.compressionConfig() orelse return false;

View File

@@ -24,11 +24,11 @@ pub const COMPRESSION_ENABLED_BY_DEFAULT = false;
/// - Only caches variants that clients actually request (lazy)
/// - Compression often makes files smaller, but we store BOTH original and compressed
///
/// ## Not Supported (Yet):
/// - Dynamic routes (would need LRU cache with TTL and size limits)
/// - Streaming responses
/// - Cache eviction or memory limits
/// - Selective caching per-route
/// ## Not Supported:
/// - **Dynamic routes** - Responses from fetch() handlers (would need LRU cache with TTL)
/// - **Streaming responses** - ReadableStream bodies are rejected from static routes (see StaticRoute.zig:160)
/// - **Cache eviction** - No memory limits or LRU eviction
/// - **Per-route control** - Can only enable/disable globally or per-algorithm
///
/// ## Usage:
/// ```js