Overview
Pounce negotiates content-encoding automatically based on the client'sAccept-Encodingheader. Priority order:
- zstd — Best compression ratio, lowest CPU cost (Python 3.14 stdlib, PEP 784)
- gzip — Universal browser support (stdlib
zlib) - identity — No compression (fallback)
All compression uses Python standard library modules — zero external dependencies.
Configuration
Compression is enabled by default:
# Disabled (compression is enabled by default)
pounce myapp:app --no-compression
Programmatically:
import pounce
pounce.run(
"myapp:app",
compression=True,
compression_min_size=500, # bytes
)
Minimum Size
Responses smaller thancompression_min_size(default: 500 bytes) are sent uncompressed. Compressing tiny responses adds CPU cost without meaningful size reduction.
Zstd (PEP 784)
Python 3.14 includescompression.zstdin the standard library. Zstd provides:
- Better ratios than gzip at similar speeds
- Lower CPU cost than gzip at similar ratios
- Streaming mode — Pounce compresses response chunks as they're sent
Modern browsers (Chrome, Firefox, Safari) supportzstdcontent-encoding.
Skipped Responses
Compression is automatically skipped for:
- SSE responses —
text/event-stream(streaming requires unbuffered delivery) - HEAD requests — No response body to compress
- Bodyless status codes — 1xx, 204, 304 responses
- Responses below
compression_min_size— Default: 500 bytes
Note
WebSocket compression uses a separate system (permessage-deflate via thewebsocket_compressionconfig option) and is not related to content-encoding compression.
See Also
- Performance — Streaming-first design
- ServerConfig — Compression settings