All Products
Search
Document Center

CDN:Gzip compression

Last Updated:Aug 12, 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

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

    Note: Enabling Gzip 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.

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

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

Usage notes

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

  • 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 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 compare the file received before and after enabling the feature. If the response header contains Content-Encoding: gzip, the file has been successfully compressed.

API reference

BatchSetCdnDomainConfig