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:
# Enabled (default)
pounce myapp:app --compression
# Disabled
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 Content Types
Compression is automatically skipped for already-compressed content:
- Images (
image/*) - Video (
video/*) - Audio (
audio/*) - Archives (
application/zip,application/gzip, etc.) - WebSocket frames
See Also
- Performance — Streaming-first design
- ServerConfig — Compression settings