Overview
Menu

Smart Compression

Function Introduction

EdgeOne enables Gzip or Brotli compression globally by default. When the client request header carries Accept-Encoding: br, gzip or Accept-Encoding: br or Accept-Encoding: gzip, the node will intelligently compress files based on their Content-Type. Compressed files can effectively reduce the size of resources and speed up content transmission. Enabling smart compression can help you:
1. Improve user experience: By reducing resource size, web page loading speed can be significantly improved, providing a better user experience. Especially for websites with a large amount of CSS, JavaScript, and other resources, enabling compression can greatly reduce loading time.
2. Save traffic: Compressed resources will consume less network traffic, which will help reduce operational costs.

Directions

Note:
By default, you do not need to modify this configuration. If in some scenarios, such as: the current client will perform MD5 verification on the file or the current client does not support parsing the specified compressed file, and you want the current site to use only Brotli compression or Gzip compression, or not to compress at all, you can follow the steps below.

Scenario 1: Enable/Disable Smart Compression for All Domain Names of the Site

If you need to enable/disable smart compression for the whole connected site, please refer to the following steps:
1. Log in to the EdgeOne console and click Site List in the left sidebar. In the site list, click the target site to enter the site details page.
2. On the site details page, click Site Acceleration > File Optimization to enter the network optimization details page.
3. Find the smart compression configuration card, which is enabled by default. Click the switch to configure enable/disable.




Scenario 2: Enable/Disable Smart Compression for Specific Domain Names

If you only need to enable/disable smart compression for specific domain names, please refer to the following steps:
1. Log in to the EdgeOne console and click Site List in the left sidebar. In the site list, click the target site.
2. On the site details page, click Rule Engine.
3. On the rule engine management page, click Create Rule to enter the new rule editing page.
4. On the rule editing page, select the Host matching type to match requests for specific domain names.
5. Click Operation > Select Box, and in the pop-up operation list, select the operation as Smart Compression, and click the switch to enable/disable Gzip or Brotli compression.



6. Click Save and Publish to complete the rule configuration.

Related References

Smart Compression Effective Rules

1. Smart compression supports file size range:256B - 30MB。
2. Smart compression is synchronous compression, compressing files while fetching them from the origin. When the node first requests a compressed file, it can directly respond with the compressed file.
3. Smart compression compresses files based on Content-Type by default, supporting the following types:
text/html
text/xml
text/plain
text/css
text/javascript
application/json
application/javascript
application/x-javascript
application/rss+xml
application/xmltext
image/svg+xml
image/tiff
text/richtext
text/x-script
text/x-component
text/x-java-source
text/x-markdown
text/js
image/x-icon
image/vnd.microsoft.icon
application/x-perl
application/x-httpd-cgi
application/xml
application/xml+rss
application/vnd.api+json
application/x-protobuf
multipart/bag
multipart/mixed
application/xhtml+xml
font/ttf
font/otf
font/x-woff
application/vnd.ms-fontobject
application/ttf
application/x-ttf
application/otf
application/x-otf
application/truetype
application/opentype
application/x-opentype
application/font-woff
application/eot
application/font
application/font-sfnt
application/wasm
application/javascript-binast
application/manifest+json
application/ld+json
4. If you have both Gzip and Brotli compression enabled at the same time, and the client request header Accept-Encoding carries both br and gzip:
If the node already has cached content, it will respond according to the following rules:
If the node has both Brotli and gzip compressed cache content, it will prioritize responding with Brotli compression.
If the node only has Brotli compressed cache content, it will prioritize responding with Brotli compression.
If the node only has gzip compressed cache content, it will prioritize responding with Gzip compression.
If the node does not have cached content, it will prioritize responding with Brotli compression.
5. When only Brotli compression is enabled, if the request compression header is gzip, the compression will not take effect, and the original resources will be returned; when only Gzip compression is enabled, if the request compression header is br, the compression will not take effect, and the original resources will be returned.
6. If the origin server has enabled compression and the server carries response headers: Content-Encoding, the smart compression function will no longer be effective.

Request Example

Not Enabled Smart Compression First request for gzip compressed file, not hit node cache, fetch the original file from the origin and cache it to the node, EdgeOne responds with the original file:



Enabled Smart Compression
First request for gzip compressed file, not hit node cache, fetch the file from the origin, node synchronously compresses and caches the compressed file, EdgeOne responds with the compressed file:
Smart compression supports streaming compression, and if the request does not hit the node cache, it will respond in a chunked manner after fetching the file from the origin.



Subsequent requests, hit the node cache of gzip compressed file, the node directly responds with the compressed file.