---
title: "File compression algorithms"
sidebar_label: "File compression algorithms"
description: "What file compression algorithms are available and how to enable the Brotli compression algorithm"
sidebar_position: 5
---

import Formbricks from '@theme/MDXComponents/Formbricks';

# File compression algorithms

:::info

File compression is available if you select [content delivery optimization type](/cdn/content/content-delivery-optimization.mdx) — Static.

:::

Compression algorithms are suitable for text formats, for example: `HTML`, `CSS`, `JS`, `JSON`, `XML`, `SVG` and others. The algorithms work on the same principle: they find repeating fragments in a file and replace them with links to the first occurrence — this reduces the file size.

Compression algorithms are not suitable for processing already compressed files, for example, raster images, audio and video files, and archives. To manage image quality and format (for example, to convert to WebP), you can enable the [Image Optimization](/cdn/content/image-optimization.mdx) service.

CDN supports two compression algorithms:

* [Gzip](#gzip) — a common algorithm: it works with all HTTP protocols, supports HTTPS, and is compatible with all browsers. Gzip is enabled by default;
* [Brotli](#brotli) — 20% more efficient than Gzip, but it only works over HTTPS, with modern browsers, and with certain file types. Brotli can be enabled additionally.

You can use both algorithms simultaneously. The CDN will automatically determine which one is supported by the user's browser and deliver the file compressed with the appropriate algorithm.

## Gzip compression algorithm \{#gzip}

Gzip works without restrictions:

* supports HTTP and HTTPS;
* compatible with all browsers;
* applies to all file types.

Gzip is enabled by default; we do not recommend disabling it. If you have [disabled](#disable-gzip) Gzip, you can [enable](#enable-gzip) it at any time.

### Enable Gzip compression algorithm \{#enable-gzip}

1. In the [control panel](https://my.selectel.ru/cdn-v3), on the top menu, click **Products** and select **CDN**.

2. In the **CDN Resources** section, open the resource page → **Optimization** tab.

3. Ensure that **Delivery optimization type** is set to **Static**.

4. In the **Compression** block, select the **Gzip compression** checkbox.

5. Click **Apply**. While settings are being applied, the resource enters the `PROCESSING` status. You cannot apply other settings during this time. Settings take effect when the resource transitions to `ACTIVE`.

### Disable Gzip compression algorithm \{#disable-gzip}

We do not recommend disabling Gzip unless you are using an alternative compression method at the origin. Without compression, files will be transferred at their original size. This will increase load times for users and the amount of CDN traffic consumed.

1. In the [control panel](https://my.selectel.ru/cdn-v3), on the top menu, click **Products** and select **CDN**.

2. In the **CDN Resources** section, open the resource page → **Optimization** tab.

3. In the **Compression** block, clear the **Gzip compression** checkbox.

4. Click **Apply**. While settings are being applied, the resource enters the `PROCESSING` status. You cannot apply other settings during this time. Settings take effect when the resource transitions to `ACTIVE`.

## Brotli compression algorithm \{#brotli}

Brotli is a compression algorithm that provides a higher compression ratio than Gzip — on average by 20%.

Brotli has limitations:

* works only over HTTPS;
* compatible only with modern browsers;
* processes only certain file types.

List of file types processed by Brotli:

* `application/javascript;`
* `application/json;`
* `application/vnd.apple.mpegurl;`
* `application/vnd.ms-fontobject;`
* `application/x-font-opentype;`
* `application/x-font-truetype;`
* `application/x-font-ttf;`
* `application/x-javascript;`
* `application/xml;`
* `application/xml+rss;`
* `font/eot;`
* `font/opentype;`
* `font/otf;`
* `image/svg+xml;`
* `image/vnd.microsoft.icon;`
* `image/x-icon;`
* `text/compressible;`
* `text/css;`
* `text/javascript;`
* `text/xml.`

### Enable Brotli compression algorithm \{#enable-brotli}

1. In the [control panel](https://my.selectel.ru/cdn-v3), on the top menu, click **Products** and select **CDN**.

2. In the **CDN Resources** section, open the resource page → **Optimization** tab.

3. Ensure that **Delivery optimization type** is set to **Static**.

4. In the **Compression** block, select the **Brotli compression** checkbox.

5. Click **Apply**. While settings are being applied, the resource enters the `PROCESSING` status. You cannot apply other settings during this time. Settings take effect when the resource transitions to `ACTIVE`.

### Disable Brotli compression algorithm \{#disable-brotli}

1. In the [control panel](https://my.selectel.ru/cdn-v3), on the top menu, click **Products** and select **CDN**.

2. In the **CDN Resources** section, open the resource page → **Optimization** tab.

3. In the **Compression** block, clear the **Brotli compression** checkbox.

4. Click **Apply**. While settings are being applied, the resource enters the `PROCESSING` status. You cannot apply other settings during this time. Settings take effect when the resource transitions to `ACTIVE`.

## Check compression algorithm performance \{#check-compression}

1. Go to your website that is delivered via CDN.

2. Open developer tools → **Network \*\*\*\* tab**.

3. In the **Name** block, click the line with the CSS or JS file.

4. On the **Headers** tab, in the **Response headers** block, find the **Content-Encoding** header:

   * if the header value is `gzip`, the [Gzip compression algorithm](#gzip) is applied;
   * if the header value is `br`, the [Brotli compression algorithm](#brotli) is applied;
   * if the header is missing, compression is not applied. This may happen because compression algorithms are disabled in the CDN resource settings or only Brotli compression is enabled, which is not supported by the user's browser.

5. If the **Content-Encoding** header is missing, check in the CDN resource settings that [Gzip compression is enabled](#enable-gzip) and, if necessary, [Brotli](#brotli).

<Formbricks />
