Description
For an API Gateway REST API, minimumCompressionSize sets the minimum payload size for compression in bytes. Compression improves transfer efficiency and does not replace encryption.
Potential impact
Uncompressed large responses can increase transfer volume and latency. For small responses, compression overhead can outweigh its benefit.
Remediation
When needed, set provider.apiGateway.minimumCompressionSize to a value from 0 through 10485760. Tune the threshold using actual responses and client compression support.
Examples
These Serverless Framework 4 excerpts set a 1024-byte threshold. REST API function and event definitions are omitted.
Before
yaml
service: my-service
frameworkVersion: '4'
provider:
name: aws
apiGateway: {}
After
yaml
service: my-service
frameworkVersion: '4'
provider:
name: aws
apiGateway:
minimumCompressionSize: 1024