How do I troubleshoot issues with compressing files in CloudFront?
"I'm using Amazon CloudFront distribution to automatically serve compressed objects, but the content is not compressed in the viewer. How can I troubleshoot this?"
"I'm using Amazon CloudFront distribution to automatically serve compressed objects, but the content is not compressed in the viewer. How can I troubleshoot this?ResolutionCheck your CloudFront configurationMake sure the Compress objects automatically setting is set to Yes.Confirm that both Brotli and Gzip are enabled in the cache policy settings.Confirm that the TTL values in the cache policy are set to a value greater than zero. CloudFront doesn't compress objects when caching is turned off.Check the configuration for viewersFirst, get information about the detailed request headers sent by the browser bycapturing the HTTP Archive (HAR). Then, confirm the following:The request uses an HTTP version higher than HTTP 1.0. In lower version of HTTP, CloudFront removes the Accept-Encoding header and doesn't compress the object in the response.The Accept-Encoding header is included in the viewer request and contains either the gzip or br value.Verify the response that the origin server is returning to CloudFrontIf you have access to the origin, check the response that the origin server is returning to CloudFront. Then, confirm the following:The origin doesn't return a Content-Encoding header. This header indicates that the response is already compressed.The response Content-Length is present in the response from the origin and is within the supported range of 1,000 bytes to 10,000,000 bytes.The file type is supported for compression.The response HTTP status code is either 200, 403 or 404.If you observe a cache hit for the object, invalidate it from the cache. CloudFront doesn't compress objects that are already cached in edge locations when you turn on the compress image setting. CloudFront returns the "X-Cache: Hit from CloudFront" response when requests are served from the edge cache.Follow"