Compressing response bodies
Compressing the response body to save bandwidth is a common practice. To take some work off your shoulder, we built the capabilities directly into Deploy.
Deno Deploy supports brotli and gzip compression. Compression is applied when the following conditions are met.
- The request to your deployment has
Accept-Encoding
header set to eitherbr
(brotli) orgzip
. - The response from your deployment includes the
Content-Type
header. - The provided content type is compressible; we use this database to determine if the content type is compressible.
- The response body size is greater than 20 bytes.
When Deploy compresses the response body, it will set Content-Encoding: gzip
or Content-Encoding: br
header to the response based on the compression
algorithm used.
When is compression skipped? Jump to heading
Deno Deploy skips the compression if:
- The response has
Content-Encoding
header. - The response has
Content-Range
header. - The response's
Cache-Control
header hasno-transform
value (e.g.cache-control: public, no-transform
).
What happens to my Etag
header? Jump to heading
When you set an Etag header with the response, we convert the header value to a Weak Etag if we apply compression to your response body. If it is already a Weak Etag, we don't touch the header.
Help us make these docs great!
Make a contribution
Deno's docs are open source. See something that's wrong or unclear? Submit a pull request:
Edit this page