All Products
Search
Document Center

CDN:Page optimization

Last Updated:Jun 21, 2026

When you enable HTML optimization, Alibaba Cloud CDN automatically removes redundant content, such as comments and extra whitespace, from HTML pages and inline JavaScript and CSS code. This reduces file sizes and improves content delivery efficiency.

Usage notes

  • Do not enable HTML optimization if your origin server uses an MD5 verification mechanism.

    When HTML optimization is enabled, Alibaba Cloud CDN modifies the file content, which changes the file's MD5 value. This results in an MD5 mismatch with the original file on the origin server.

  • If your origin server has Gzip compression or Brotli compression enabled, the HTML optimization feature of Alibaba Cloud CDN does not take effect. Alibaba Cloud CDN passes the compressed files from the origin server directly to the client.

    If you want to use the HTML optimization feature without disabling Gzip or Brotli compression on your origin server, you can configure the origin HTTP header in to remove the Accept-Encoding header. After removes the Accept-Encoding header during an origin fetch, the HTML optimization feature can work correctly. To remove the Accept-Encoding header, see Modify outbound request headers.

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

  • In some cases, HTML optimization can affect your website's business logic. If clients encounter errors such as Hydration completed but contains mismatches. when they visit the optimized web page, disable HTML optimization to resolve the issue.

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 HTML Optimization section, turn on the switches for HTML Optimization, CSS Optimization, or JavaScript Optimization.

    Note

    HTML optimization is the master switch for this feature. You must enable it before you can enable CSS optimization or JavaScript optimization.

    • Enable HTML Optimization to optimize HTML pages.

    • Enable CSS Optimization to optimize CSS code.

    • Enable JavaScript Optimization to optimize JavaScript code.

API reference

BatchSetCdnDomainConfig