Method Description of CLB Enabling Gzip Configuration and Detection
Last Updated At: 2026-08-14 08:08:00
In Public Network CLB instance, HTTP/HTTPS protocol supports users to enable the gzip compression feature by default. Enabling the gzip feature to compress web pages can effectively reduce the amount of data transmitted over the network and increase the access speed of client browsers. During use, pay attention to the following matters:
Notes
GZIP support should also be enabled for the backend CVM instances.
For common Nginx service containers, GZIP must be enabled in the configuration file (nginx.conf by default) and the service must be restarted.gzip on;The file types currently supported by the CLB are as follows. You can specify the file type for compression in the gzip_types configuration item
application/atom+xml application/javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component;
Description:
The GZIP support for the above file types must be enabled in the CLB backend CVM business software.
The client request must include a compression request header.
For compression to be enabled, the client request must carry the following header:Accept-Encoding: gzip,deflate,sdch
Sample of Backend CVM Enabling GZIP Process Support
Sample of CVM Running Environment: Debian 6
Use vim to open the Nginx configuration file according to the user path:
vim /etc/nginx/nginx.confFind the following code:
gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 2; gzip_types text/html application/json;
The syntax details of the above code is as follows:
- gzip: Enable or disable the gzip module.
Syntax:gzip on/off
Scope: http, server, location - gzip_min_length: specifies the minimum number of bytes for a page to be eligible for compression. The page's byte size is obtained from the Content-Length header. The default value is 1k.
Syntax:gzip_min_length length
Scope: http, server, location - gzip_buffers: specifies the number of units of memory that the system allocates to store the compressed data stream for GZIP. If the size is set to 16k, memory will be allocated in 16k units, with 4 times the original data size being requested.
Syntax:gzip_buffers number size
Scope: http, server, location - gzip_http_version: specifies the minimum HTTP version required to use GZIP. Setting this parameter to HTTP/1.0 means that GZIP compression can be used for HTTP 1.0 and later versions, thus ensuring upward compatibility with HTTP/1.1. Since Converge Cloud now fully supports HTTP/1.1 across the network; no changes are needed.
Syntax:gzip_http_version 1.0 | 1.1;
Scope: http, server, location - gzip_comp_level: specifies the GZIP compression level, ranging from 1 to 9. A level of 1 provides the lowest compression ratio and the fastest processing speed, while a level of 9 provides the highest compression ratio and the slowest processing speed (faster transmission, but more CPU-intensive).
Syntax:gzip_comp_level 1..9
Scope: http, server, location - gzip_types: Match the MIME type for compression. By default, the text/html type is compressed. In addition, gzip under Nginx does not compress static resource files such as javascript and images by default. You can specify the MIME type that needs to be compressed through gzip_types. If it is not a set value, no compression is performed. For example, if you need to compress json format data, you need to add application/json type data in this statement.
The supported types are as follows:
text/html text/plain text/css application/x-javascript text/javascript application/xml
Syntax: gzip_types mime-type [mime-type ...]
Scope: http, server, location.
If you have modified the configuration, save the file and exit, then go to the Nginx bin file directory and execute the following command to reload Nginx:
./nginx -s reload
Use the curl command to test whether gzip is successfully enabled:
curl -I -H "Accept-Encoding: gzip, deflate" "http://convergecloud.com/example/"