Updated on 2025-08-05 GMT+08:00

Configuring Data Compression for an HTTP or HTTPS Listener

You can enable data compression for HTTP and HTTPS listeners to reduce the data size to be transferred, speed up transfers, and lower bandwidth usage.

Data Compression Overview

When sending an HTTP or HTTPS request, the client includes Accept-Encoding:gzip,deflate,br,* in the request header, indicating that the client supports data compression and writes the compression algorithms it supports into the request header. Upon receiving the request, the server checks the Accept-Encoding header to determine which compression algorithms the client supports. Based on its own configuration and capabilities, the server selects one of the supported compression algorithms to compress the response body and includes Content-Encoding in the response header to notify the client that the response has been encrypted and the encryption algorithm used.

Compression is handled at every point in the communication chain (client, load balancer, and backend servers). For example, if a backend server compresses a response, ELB sends the response directly to the client without compressing the response again. ELB can only compress the response body whose status code is 200, 403, and 404.

Figure 1 Response body compressed by the load balancer
Figure 2 Response body compressed by the backend server

Constraints

Brotli and Gzip can compress the files in the following format: text/html, tex/xml, text/plain text/css, application/javascript, application/x-javascript, application/rss+xml, application/atom+xml, application/xml, and application/json.

Enabling Data Compression for an HTTP or HTTPS Listener

You can enable data compression when adding an HTTP or HTTPS listener or enable it later.

  1. Go to the load balancer list page.
  2. Add an HTTP or HTTPS listener in either of the following ways:
    • On the displayed page, locate the load balancer and click its name. On the Listeners tab, click Add Listener.
    • On the displayed page, locate the load balancer and click Add Listener in the Operation column.
  3. On the Add Listener page, expand Advanced Settings (Optional) and enable data compression as needed.
    Figure 3 Enabling data compression
  4. Configure other parameters of the listener as prompted.
  5. Confirm the configurations and click Submit.