ESA compresses static resources to reduce data transfer sizes and improve page load speeds.
Introduction
ESA provides three compression methods: Gzip, Brotli, and Zstd. They differ in compression efficiency, decompression speed, and compatibility, making them suitable for different scenarios.
Compression type | Compression efficiency | Compatibility | Use case |
Gzip | Fast compression, medium decompression speed | High | General web services |
Brotli | Slow compression, high decompression speed | Medium | Static resource optimization |
Zstd | Very fast compression, very fast decompression | Low | Real-time stream data processing |
The Entrance plan only supports Zstd compression.
Notes
If you enable Gzip, Brotli, and Zstd at the same time, they are applied in the following order: Zstd > Brotli > Gzip.
ESA supports compression for the following file types:
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.
Cases where compression rules do not take effect
Compression rules are not applied in certain cases because of conflicting settings on the origin server or client.
For origin server
Gzip or Brotli compression is applied only to files from the origin server that are between 1 KB and 10 MB. Files outside this size range are not compressed.
If the response from the origin server includes the
Content-Encodingheader, ESA does not apply compression.If the response from the origin server contains the
cache-control: no-transformHTTP header, ESA does not apply compression.
For client
If a client does not support the configured compression algorithm, the response is not compressed. Client support is indicated by the Accept-Encoding request header.
Add a file compression rule
In the ESA console, select Websites. In the Website column, click the target site.
In the navigation pane on the left, select .
Click Create Rule and enter a Rule Name.
In the If requests match... section, set the conditions that the request must match. For more information about how to configure rules, see Components of a rule expression.
In the Then execute... section, enable the required compression method.
Rule item
Description
Rule Name
A custom rule name. It can contain Chinese characters, letters (case-sensitive), digits (0-9), and underscores (
_). The name can be up to 64 characters long.Matching conditions
Set the request features that the rule must match.
Click the logical operator And or Or to add a condition. You can add up to five conditions to a rule.
Each condition consists of a Matching field, a Logical operator, and a Matching content.
Compression method
You can choose to enable only Gzip, Brotli, or Zstd. If you enable all three compression methods, Zstd has the highest priority, followed by Brotli.
References
Rule-related features vary in execution priority, rule behavior, and configuration scope. For more information, see How ESA rules take effect.