After you enable gzip compression, DCDN points of presence (POPs) compress resources with gzip before returning them to clients. This reduces file sizes, improves file transfer efficiency, and lowers bandwidth consumption.
Background information
Compression includes gzip compression and Brotli compression. For more information about Brotli compression, see Brotli compression.
Gzip or Brotli compression can be used only when the source file size is between 1 KB and 10 MB. Files smaller than 1 KB or larger than 10 MB are not compressed.
File types supported by Gzip compression include:
text/xml,text/plain,text/css,application/javascript,application/x-javascript,application/rss+xml,text/javascript,image/tiff,image/svg+xml,application/json, andapplication/xml.The client request includes the request header
Accept-Encoding: gzip: This indicates the client can accept a Gzip-compressed version of the resource.The server response includes the response header
Content-Encoding: gzip: This indicates that the content of the response is a Gzip-compressed resource.
Notes
gzip compression is compatible with all browsers. Brotli compression is not compatible with some older browsers. Check browser compatibility based on your business needs.
Compressing static files changes their MD5 value. If your website's business logic uses MD5 file verification (i.e., the client needs to verify the MD5 value of the file obtained from the CDN/DCDN node, and a mismatch between the verified MD5 value and the one in the response header indicates a download failure), please disable the Gzip and Brotli compression features.
If compression is enabled on the origin server and the server response includes the
Content-Encodingheader, the compression feature of CDN/DCDN will no longer take effect.If both Gzip and Brotli compression are enabled, and the client's
Accept-Encodingrequest header includes bothbrandgzip, only Brotli compression will take effect.-
If you enable both HTML Optimization and a compression feature (Gzip compression or Brotli compression), HTML Optimization will not take effect. DCDN will only compress the files.
Common image file formats, such as PNG, JPG, and JPEG, and video file formats, such as MP4, AVI, and WMV, are already compressed. Enabling gzip compression or Brotli compression provides no additional benefit for these file types. Disable compression for these formats. To further reduce image file sizes, use the image processing feature. To further reduce video file sizes, use the audio and video transcoding feature.
Procedure
-
Log on to the DCDN console.
-
In the left-side navigation pane, click Domain Names.
-
On the Domain Names page, find the domain name that you want to manage and click Configure.
-
In the left-side navigation tree of the domain name, click Optimization.
In the Gzip Compression section, turn on the Gzip Compression switch.
After you enable the Gzip compression feature, you can compare the file type received from the original request with the file type received after compression is enabled. If you receive a file with a
.gzipsuffix, this indicates that the file has been compressed.
FAQ
Related APIs
BatchSetDcdnDomainConfigs: Call the BatchSetDcdnDomainConfigs operation to configure the gzip feature for multiple domain names at once.