tencent cloud

All product documents
API Gateway
Compressing Responses
Last updated: 2023-12-22 09:49:10
Compressing Responses
Last updated: 2023-12-22 09:49:10

Overview

For the HTTP protocol, compressing the response data can reduce the amount of data transferred, thereby shortening response time, saving server bandwidth, and improving client performance. This task guides you on how to compress a response through API Gateway.

Interaction Process





Operation Description

By default, API Gateway supports response compression based on the GZIP compression algorithm. To implement this feature, the following requirements need to be met:
The client request contains the Accept-Encoding header and its value contains gzip.
The response body size of the client is greater than 1 KB.
Content-Type of the response body is text/xml, text/plain, text/css, application/javascript, application/x-javascript, application/rss+xml, application/xml, application/json, or application/octet-stream.
If the client request meets the requirements above, API Gateway will return the compressed response body to the client and contain the Content-Encoding: gzip header in the response.

Notes

Response compression supports only the HTTP and HTTPS protocols but not WebSocket.
If the backend is connected to SCF and response integration is enabled, the structure that SCF returns to API Gateway cannot contain the Content-Encoding: gzip header. Otherwise, response compression will not take effect.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon