Skip to main content
All CollectionsUpstreams
Automated Compression of Responses with Gzip and Zstd
Automated Compression of Responses with Gzip and Zstd

Learn how to increase speed and efficiency of your custom domains by enabling automatic compression of responses.

Drago Crnjac avatar
Written by Drago Crnjac
Updated over a week ago

Overview

To improve the speed and efficiency of your web services hosted through SaaS Custom Domains, you can easily enable automated response compression. This feature uses advanced compression algorithms like Gzip and Zstandard to reduce data transfer size and enhance loading times. This guide will walk you through the simple steps to enable compression in your application settings.

Benefits of Enabling Compression

  • Reduced Bandwidth Usage: Compression significantly decreases the amount of data transferred between your server and users.

  • Improved Page Load Times: Compressed content loads faster, providing a better experience for end-users.

  • Cost Efficiency: Lower data transfer volumes can reduce hosting and data transfer costs.

Enabling Compression for Upstreams

Compression is enabled on the upstream level. If you enable compression for an upstream, the responses from all of its custom domains will benefit from it.

You can enable compression when creating the upstream, or you can edit an existing upstream β€” simply tick the Compression checkbox and you're all set.

How Compression Works

We use Gzip and Zstandard. These are two of the most effective compression algorithms. Gzip is widely supported and offers good compression for all types of content, while Zstandard is newer and can provide faster compression and decompression speeds with better ratios.

Once enabled, all responses from your upstream services through custom domains will be automatically compressed if they meet the minimum size requirements of 512 bytes. For smaller sizes the benefits of compression are minimal so we skip compressing those responses.

Content Types and Compression

Compression is most effective with text-based content such as HTML, CSS, JavaScript, and JSON. The system is designed to target these types of content for compression.

Here's the full list of Content-Type headers for which we compress responses:

application/atom+xml*
application/eot*
application/font*
application/geo+json*
application/graphql+json*
application/javascript*
application/json*
application/ld+json*
application/manifest+json*
application/opentype*
application/otf*
application/rss+xml*
application/truetype*
application/ttf*
application/vnd.api+json*
application/vnd.ms-fontobject*
application/wasm*
application/x-httpd-cgi*
application/x-javascript*
application/x-opentype*
application/x-otf*
application/x-perl*
application/x-protobuf*
application/x-ttf*
application/xhtml+xml*
application/xml*
font/*
image/svg+xml*
image/vnd.microsoft.icon*
image/x-icon*
multipart/bag*
multipart/mixed*
text/*

Additionally, the request has to include the Accept-Encoding header with one of our compression algorithms as a value β€” gzip or zstd β€” to trigger the compression.

For example, valid Accept-Encoding headers can look like this:

Accept-Encoding: gzip
Accept-Encoding: zstd
Accept-Encoding: zstd, gzip, br

If multiple compression algorithms are requested, we'll most likely pick zstd.

If your upstream / origin server has already compressed the response, we'll pass the response through without trying to compress anything ourselves.

That's it! Now you know everything about enabling compression for your custom domains.

Until next time, keep building!


Need more help? Reach out via the Intercom chat widget and we'll be right with you!

Did this answer your question?