Updated on 2024-04-10 GMT+08:00

Smart Compression

Background

If smart compression is enabled, CDN automatically compresses your static files. This can save you a lot of bandwidth by reducing file size and speed up file transfer. Smart compression includes gzip compression and Brotli compression. The performance of Brotli compression is 15% to 25% higher than that of gzip compression.

Precautions

  • Smart compression applies to JS, HTML, CSS, XML, JSON, SHTML, and HTM files.
  • Do not enable this function if MD5 verification has been configured for your origin server. When CDN compresses static files, the MD5 value is changed. As a result, the MD5 value of the compressed file is different from that of the file on the origin server.
  • Some browsers do not support Brotli compression. Check supported browsers on this website.
  • You cannot enable smart compression for domain names with special configurations.
  • If both gzip and Brotli compression are enabled, Brotli compression is preferentially performed.
  • General image files (such as PNG, JPG, and JPEG) and video files (such as MP4, AVI, and WMV) have already been compressed. Therefore, you do not need to enable smart compression (gzip or Brotli) for these files.

Procedure

  1. Log in to Huawei Cloud console. Choose Service List > Content Delivery & Edge Computing > Content Delivery Network.

    The CDN console is displayed.

  2. In the navigation pane, choose Domains.
  3. In the domain list, click the target domain name or click Configure in the Operation column.
  4. Click the Advanced Settings tab.
  5. Click Edit next to Smart Compression.
    Figure 1 Smart compression
    Table 1 Parameter description

    Parameter

    Description

    Status

    Turn on or off the switch.

    Compression Mode

    Gzip or Brotli compression. If both are selected, Brotli compression is used.

    Format

    Enter file name extensions and multipurpose internet mail extensions (MIME).

    • A single extension contains up to 50 characters and all extensions contain up to 2,000 characters. Separate extensions by semicolon (;).
    • If this parameter is left empty, the default value .js;.html;.css;.xml;.json;.shtml;.htm is used.

    File Size

    Select Enabled and specify a file size range (0 MB to 30 MB). Files in this range will be compressed.

  6. Select a compression method and click OK.