File compression algorithms
File compression is available if you select content delivery optimization type — 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 service.
CDN supports two compression algorithms:
- Gzip — a common algorithm: it works with all HTTP protocols, supports HTTPS, and is compatible with all browsers. Gzip is enabled by default;
- 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 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 Gzip, you can enable it at any time.
Enable Gzip compression algorithm
-
In the control panel, on the top menu, click Products and select CDN.
-
In the CDN Resources section, open the resource page → Optimization tab.
-
Ensure that Delivery optimization type is set to Static.
-
In the Compression block, select the Gzip compression checkbox.
-
Click Apply. While the settings are being applied, the resource status will be
PROCESSING. You cannot apply other settings at this time. The settings will be applied once the resource status changes toACTIVE.
Disable Gzip compression algorithm
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.
-
In the control panel, on the top menu, click Products and select CDN.
-
In the CDN Resources section, open the resource page → Optimization tab.
-
In the Compression block, clear the Gzip compression checkbox.
-
Click Apply. While the settings are being applied, the resource status will be
PROCESSING. You cannot apply other settings at this time. The settings will be applied once the resource status changes toACTIVE.
Brotli compression algorithm
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
-
In the control panel, on the top menu, click Products and select CDN.
-
In the CDN Resources section, open the resource page → Optimization tab.
-
Ensure that Delivery optimization type is set to Static.
-
In the Compression block, select the Brotli compression checkbox.
-
Click Apply. While the settings are being applied, the resource status will be
PROCESSING. You cannot apply other settings at this time. The settings will be applied once the resource status changes toACTIVE.
Disable Brotli compression algorithm
-
In the control panel, on the top menu, click Products and select CDN.
-
In the CDN Resources section, open the resource page → Optimization tab.
-
In the Compression block, clear the Brotli compression checkbox.
-
Click Apply. While the settings are being applied, the resource status will be
PROCESSING. You cannot apply other settings at this time. The settings will be applied once the resource status changes toACTIVE.
Check compression algorithm performance
-
Go to your website that is delivered via CDN.
-
Open developer tools → Network **** tab.
-
In the Name block, click the line with the CSS or JS file.
-
On the Headers tab, in the Response headers block, find the Content-Encoding header:
- 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 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.
- if the header value is
-
If the Content-Encoding header is missing, check in the CDN resource settings that Gzip compression is enabled and, if necessary, Brotli.