Skip to main content

File compression algorithms

For your information

File compression is available if the selected content delivery optimization type is Static.

Compression algorithms are suitable for text formats, such as 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 encountered fragment, reducing the file size.

Compression algorithms are not suitable for processing already compressed files, such as raster images, audio and video files, and archives. To manage image quality and format (for example, convert to WebP), you can enable the Image Optimization service.

CDN supports two compression algorithms:

  • Gzip is a common algorithm: it works with all versions of the HTTP protocol, supports HTTPS, and is compatible with all browsers. Gzip is enabled by default;
  • Brotli is 20% more effective than Gzip, but 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 supports HTTP and HTTPS protocols and is compatible with all browsers.

List of file types processed by Gzip by default:

  • application/atom+xml;
  • application/javascript;
  • application/json;
  • application/rss+xml;
  • application/vnd.apple.mpegurl;
  • application/vnd.ms-fontobject;
  • application/x-font-opentype;
  • application/x-font-truetype;
  • application/x-font-ttf;
  • application/x-javascript;
  • application/xhtml+xml;
  • application/xml;
  • application/xml+rss;
  • application/wasm;
  • application/bytes;
  • application/data;
  • application/bundle;
  • font/eot;
  • font/opentype;
  • font/otf;
  • font/truetype;
  • image/svg+xml;
  • image/vnd.microsoft.icon;
  • image/x-icon;
  • image/x-win-bitmap;
  • text/compressible;
  • text/css;
  • text/javascript;
  • text/plain;
  • text/xml;
  • text/html.

Чтобы включить обработку дополнительных типов файлов, создайте тикет.

По умолчанию Gzip включен, мы не рекомендуем его отключать. Если вы отключили Gzip, его можно включить в любой момент.

Enable Gzip compression algorithm

  1. In the control panel, in the top menu, click Products and select CDN.

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

  3. Make sure that in the Delivery optimization type block, Static is selected.

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

  5. Click Apply. While the settings are being applied, the resource will have the PROCESSING status. During this time, applying other settings is unavailable. The settings will be applied once the resource switches to the ACTIVE status.

Disable Gzip compression algorithm

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

  1. In the control panel, in 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 the settings are being applied, the resource will have the PROCESSING status. During this time, applying other settings is unavailable. The settings will be applied once the resource switches to the ACTIVE status.

Brotli compression algorithm

Brotli is a compression algorithm that achieves a higher compression ratio compared to Gzip—by 20% on average.

Brotli has limitations:

  • works only over HTTPS;
  • is 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

  1. In the control panel, in the top menu, click Products and select CDN.

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

  3. Make sure that in the Delivery optimization type block, Static is selected.

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

  5. Click Apply. While the settings are being applied, the resource will have the PROCESSING status. During this time, applying other settings is unavailable. The settings will be applied once the resource switches to the ACTIVE status.

Disable Brotli compression algorithm

  1. In the control panel, in 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 the settings are being applied, the resource will have the PROCESSING status. During this time, applying other settings is unavailable. The settings will be applied once the resource switches to the ACTIVE status.

Check compression algorithm operation

  1. Go to your website delivered via CDN.

  2. Open Developer Tools → Network tab.

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

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

    • if the header value is gzip, the Gzip compression algorithm is applied;
    • if the header value is br, the Brotli compression algorithm is applied;
    • if there is no header, compression is not applied. This may happen because compression algorithms are disabled in the CDN resource settings, or only the Brotli compression algorithm is enabled, which is not supported by the user's browser.
  5. If there is no Content-Encoding header, make sure in the CDN resource settings that the Gzip compression algorithm is enabled and, if necessary, Brotli.