Overview
EdgeOne enables Gzip or Brotli compression by default globally. When the client request header carries
Accept-Encoding: br, gzip, Accept-Encoding: br, or Accept-Encoding: gzip, the node will intelligently compress based on the file's Content-Type. This compression effectively reduces the size of the resources and accelerates the transmission speed of the content. Enabling intelligent compression can assist you in:1. Enhance User Experience: By reducing resource size, the loading speed of web pages can be significantly improved, thereby providing a superior user experience. Particularly for websites with a wealth of CSS, JavaScript, and other resources, enabling compression can drastically cut down on loading times.
2. Conserve Bandwidth: Compressed resources will consume less network traffic, which can help reduce operational costs.
Instructions
Note:
By default, there is no need to modify this configuration. However, in certain scenarios, such as when the current client performs an MD5 check on the file or the current client cannot parse the specified compressed file, and you wish for the current site to use only Brotli compression, Gzip compression, or no compression at all, you can follow the steps below.
Scenario 1: Enabling/Disabling Smart Compression for All Domain Names of the Site
To enable or disable smart compression for all domain names used to access the current site, refer to the following steps:
1. Log in to the EdgeOne console. In the left sidebar, click Site List. Within the site list, click the site that needs to be configured to enter the site details page.
2. On the site details page, choose Site Acceleration > File Optimization to go to the Network Optimization details page.
3. Locate the Smart Compression configuration card. By default, all options are enabled. Click the toggle to configure whether to enable or disable this feature.

Scenario 2: Enabling/Disabling Smart Compression for Specified Domain Names
To enable or disable smart compression for specified domain names, refer to the following steps:
1. Log in to the Edge Security Acceleration Platform Console. In the left-hand menu, click on Site List. Within the site list, click on the site that needs to be configured.
2. On the site details page, click Rule Engine.
3. On the rule engine management page, click Create rule to access the new rule editing page.
4. On the page that appears, select HOST from Matching type and specify an operator and a value to match the requests of specified domain names.
5. Click on Operation > Selection Box. In the pop-up operation list, select Smart Compression. Click on the Switch to enable or disable Gzip or Brotli compression.

6. Click Save and publish to complete the rule configuration.
References
Smart Compression Activation Rules
1. File size: 256 B – 30 MB
2. Smart Compression is a synchronous compression process that compresses files while retrieving them from the origin. When a compressed file is requested for the first time, the node can directly respond with the compressed file.
3. By default, Smart Compression compresses based on
Content-Type and supports the following types:text/htmltext/xmltext/plaintext/csstext/javascriptapplication/jsonapplication/javascriptapplication/x-javascriptapplication/rss+xmlapplication/xmltextimage/svg+xmlimage/tifftext/richtexttext/x-scripttext/x-componenttext/x-java-sourcetext/x-markdowntext/jsimage/x-iconimage/vnd.microsoft.iconapplication/x-perlapplication/x-httpd-cgiapplication/xmlapplication/xml+rssapplication/vnd.api+jsonapplication/x-protobufmultipart/bagmultipart/mixedapplication/xhtml+xmlfont/ttffont/otffont/x-woffapplication/vnd.ms-fontobjectapplication/ttfapplication/x-ttfapplication/otfapplication/x-otfapplication/truetypeapplication/opentypeapplication/x-opentypeapplication/font-woffapplication/eotapplication/fontapplication/font-sfntapplication/wasmapplication/javascript-binastapplication/manifest+jsonapplication/ld+json
4. If you have both Gzip and Brotli compression enabled, and the client request header
Accept-Encoding carries both br and gzip:If there is cached content within the node, it will respond according to the following rules:
If a node has cached content that is both Brotli and gzip compressed, it will prioritize responding with Brotli compression.
If a node only has cached content that is Brotli compressed, it will prioritize responding with Brotli compression.
If the node has cached resources compressed only in Gzip, Gzip compressed resources are returned first.
If there is no cached content within the node, it will prioritize responding with Brotli compression.
5. If only Brotli compression or Gzip compression is enabled and the request header carries
gzip or br, the compression will not take effect, and the original resource will be returned.6. If the origin server has enabled the compression feature and the server carries the response header:
Content-Encoding, the intelligent compression feature will no longer be effective.Sample Request
Without Smart Compression enabled:
On the first request for a gzip compressed file, if the node cache is not hit, the original file is fetched from the source and cached on the node. EdgeOne responds with the original file.

Enable Smart Compression
Upon the first request for a gzip compressed file, if the node cache is not hit, the file is retrieved from the source, compressed and cached by the node, and the compressed file is responded by EdgeOne:
Smart Compression supports chunk streaming compression. If the request does not hit the node cache, the file will be responded in chunks after being retrieved from the source.

Upon subsequent requests, if the Gzip compressed file is cached on the node, the node will directly respond with the compressed file.
