All Products
Search
Document Center

CDN:Gzip compression

Last Updated:Jun 21, 2026

After you enable Gzip compression, points of presence (PoPs) compress resources before delivering them to users. This reduces file sizes, improves transfer speeds, and lowers bandwidth consumption.

Background information

  • You can use two compression methods: Gzip compression and Brotli compression. Gzip compression uses the Gzip algorithm. For more information, see Brotli compression.

  • Gzip or Brotli compression applies only to files from the origin server that are between 1 KB and 10 MB in size. Files smaller than 1 KB or larger than 10 MB are not compressed.

  • Gzip compression is supported for the following MIME 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.

  • A client indicates that it supports Gzip-encoded content by including the Accept-Encoding: gzip request header.

  • A server indicates that a resource is Gzip-compressed by including the Content-Encoding: gzip response header.

Usage notes

  • Gzip compression is compatible with all browsers. Brotli compression is not supported by some older browser versions. You can check browser compatibility based on your business requirements.

  • When CDN or compresses a static file, the MD5 value of the file changes. If your application logic relies on MD5 value verification for files delivered from a point of presence (PoP), you must disable both Gzip compression and Brotli compression. A mismatch in MD5 values can cause client-side validation to fail, resulting in a failed download.

  • If your origin server has compression enabled and sends a response that includes the Content-Encoding header, the compression features of CDN and do not take effect.

  • If you enable both Gzip compression and Brotli compression, and a client request includes br and gzip in the Accept-Encoding header, Brotli compression takes precedence.

  • 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.

  • Common image formats like PNG, JPG, and JPEG, and video formats like MP4, AVI, and WMV, are already inherently compressed. Enabling Gzip compression or Brotli compression on these file types provides no significant benefit. We recommend that you disable compression for these file types. To further optimize images, use the image processing feature. To optimize videos, use the video transcoding feature.

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 Gzip Compression section, turn on the Gzip Compression switch.

    After you enable Gzip compression, you can verify that it is working. A successfully compressed resource is delivered with the Content-Encoding: gzip response header.

    Do not enable this feature if your origin server performs MD5 value verification because compression changes the MD5 value of files.

FAQ

Why does Gzip compression not take effect after an origin fetch?

API reference

BatchSetCdnDomainConfig