---
title: "Compression"
description: "Request compression and transfer encoding for Sentry envelope submissions."
url: https://develop.sentry.dev/sdk/foundations/transport/compression/
---

# Compression

## [Request Compression](https://develop.sentry.dev/sdk/foundations/transport/compression.md#request-compression)

SDKs are heavily encouraged to compress the request body before sending it to the server to keep the data small. The preferred method for this is to send a `content-encoding` header. The following content encodings are accepted by Relay and Sentry:

* `gzip`: Using the [LZ77](http://en.wikipedia.org/wiki/LZ77_and_LZ78#LZ77) compression algorithm.
* `deflate`: Using [zlib](http://tools.ietf.org/html/rfc1950) structure with the [deflate](http://tools.ietf.org/html/rfc1951) compression algorithm.
* `br`: Using the [Brotli](https://en.wikipedia.org/wiki/Brotli) algorithm.
* `zstd`: Using the [zstd](https://datatracker.ietf.org/doc/html/rfc8878) algorithm.

## [Transfer Encoding](https://develop.sentry.dev/sdk/foundations/transport/compression.md#transfer-encoding)

Transfer encoding is recommended for only very large requests. Set the header to `transfer-encoding: chunked`, which allows omission of the `content-length` header and requires the request body to be wrapped into chunk headers.

See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding) for more details.
