Brotli is an open-source compression algorithm that provides better performance than Gzip compression. After you enable this feature, CDN points of presence (POPs) intelligently compress resources before returning them to clients. This reduces the size of transferred files, improves delivery efficiency, and reduces bandwidth consumption.
Background
-
Compression includes Gzip compression and Brotli compression. The intelligent compression feature applies mainly to Gzip compression. For more information about intelligent compression, see Gzip compression.
-
Gzip or Brotli compression applies only to files on the origin server that are between 1 KB and 10 MB in size.
-
Brotli compression supports the following file types: text/xml, text/plain, text/css, application/javascript, application/x-javascript, application/rss+xml, text/javascript, image/tiff, image/svg+xml, application/json, and application/xml.
-
If the server response includes the
Content-Encoding: brresponse header, it indicates that the response content is Brotli-compressed. -
If a client request includes the
Accept-Encoding: brrequest header, it indicates that the client can accept Brotli-compressed content.
Usage notes
-
When CDN compresses static files, their MD5 values change. If your origin server uses an MD5 verification mechanism, disable both intelligent compression and Brotli compression.
-
If compression is enabled on the origin server and the server response includes the
Content-Encodingheader, the compression feature of CDN will not take effect. -
If you enable both Brotli compression and intelligent compression, and a client's
Accept-Encodingrequest header contains bothbrandgzip, only Brotli compression is applied. -
If you enable both HTML Optimization and a compression feature (Gzip compression or Brotli compression), HTML Optimization will not take effect. CDN will only compress the files.
-
Brotli compression is supported only by some browsers. You can check browser compatibility based on your business requirements.
-
Common image file types (such as PNG, JPG, and JPEG) and video file types (such as MP4, AVI, and WMV) are already compressed. Enabling intelligent compression or Brotli compression does not reduce their size. We recommend that you disable compression for these files. To further reduce image file sizes, use the image processing feature. To further reduce video file sizes, use the audio and video transcoding feature. Both image processing and audio and video transcoding can reduce file quality.
Procedure
-
Log on to the CDN console.
-
In the left navigation pane, click Domain Names.
-
On the Domain Names page, find the target domain name and click Manage in the Actions column.
-
In the domain's navigation pane, click Optimization.
-
In the Brotli Compression section, turn on the Brotli Compression switch.
After you enable Brotli compression, you can compare the file returned from a request made before enabling the feature with one returned after. If the returned file has a .br extension, it indicates that the file has been compressed.