Review Serverless API response compression

Choose a compression threshold suited to the responses.

Description

Set provider.apiGateway.minimumCompressionSize to the smallest REST API response size you want API Gateway to compress.

Potential impact

Compressing large responses can save bandwidth. For small ones, the extra processing can add latency. HTTPS protects the data in transit.

Remediation

Choose a threshold from 0 to 10485760 bytes. Deploy and test typical responses with a supported Accept-Encoding header.

Examples

The Framework 4 example sets a 1024-byte threshold. Add your REST API functions and events.

Before

yaml
service: my-service
frameworkVersion: '4'
provider:
  name: aws
  apiGateway: {}

After

yaml
service: my-service
frameworkVersion: '4'
provider:
  name: aws
  apiGateway:
    minimumCompressionSize: 1024

References