Brotli compression

更新时间: 2026-08-12 16:55:53

Brotli is an open-source compression algorithm that provides better performance than Gzip compression. After you enable Brotli compression, CDN points of presence (POPs) compress resources with Brotli before returning them to clients. This reduces the size of transferred files, improves delivery efficiency, and reduces bandwidth consumption.

Background information

CDN POPs support two compression methods: Gzip compression and Brotli compression. This document describes how to configure Brotli compression. For more information about Gzip 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.

    Note: Enabling Brotli compression on already-compressed file types (such as PNG and JPG images, or MP4 videos) has no effect. For more information, see the usage notes below.

  • If the server response includes the Content-Encoding: br response header, it indicates that the response content is Brotli-compressed.

  • If a client request includes the Accept-Encoding: br request header, it indicates that the client can accept Brotli-compressed content.

  • If you enable both Brotli compression and Gzip compression, and the client request header Accept-Encoding contains both br and gzip, only Brotli compression takes effect.

Usage notes

When you use Brotli compression, take note of the following items (including interactions with Gzip compression, page optimization, and other features):

  • When CDN compresses static files, their MD5 values change. If your origin server uses an MD5 verification mechanism, disable both Gzip compression and Brotli compression.

  • If compression is enabled on the origin server and the server response includes the Content-Encoding header, the compression feature of CDN will not take effect.

  • If you enable both HTML optimization and a compression feature (Gzip compression or Brotli compression), HTML optimization does not take effect. Alibaba Cloud CDN only compresses 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 Gzip 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

  1. Log on to the CDN console.

  2. In the left navigation pane, click Domain Names.

  3. On the Domain Names page, find the target domain name and click Manage in the Actions column.

  4. In the domain's navigation pane, click Optimization.

  5. In the Brotli Compression section, turn on the Brotli Compression switch.

    After you enable Brotli compression, you can compare the file received before and after enabling the feature. If the response header contains Content-Encoding: br, the file has been compressed.

API reference

BatchSetCdnDomainConfig

上一篇: Gzip compression 下一篇: Image editing
阿里云首页 CDN 相关技术圈