Definition:
Payload Compression is a technique that reduces the size of data being transmitted over a network by encoding it in a more space-efficient format. It decreases bandwidth usage, speeds up data transfer, and reduces costs, especially important for large datasets, APIs, and web applications.
Key Properties:
- Size reduction: Compresses data before transmission
- Automatic handling: Usually transparent to applications
- Multiple algorithms: gzip, deflate, brotli, etc.
- Trade-off: CPU time for bandwidth savings
- Reversible: Original data perfectly reconstructed
How It Works:
- Client requests data with compression preference
- Server compresses response using specified algorithm
- Data transmitted in compressed format
- Client decompresses and uses original data
Example:
HTTP Compression Example:
// Client Request
GET /api/users HTTP/1.1
Host: api.example.com
Accept-Encoding: gzip, deflate, br
// Server Response
HTTP/1.1 200 OK
Content-Type: application/json
Content-Encoding: gzip
Content-Length: 420
Original-Content-Length: 1247
[compressed binary data]