Is there any way to enable GZIP / Brotli compression on Cloudfront if the origin is a nginx server with SSI (Server Side Includes) enabled?
The issue seems that nginx SSI drops the Content-Length
header, as it doesn’t know the content length at the time of sending the headers as the file hasn’t been parsed. However, Cloudfront apparently requires the Content-Length
header to compress the request:
The response must include a Content-Length header so CloudFront can determine whether the size of the file is in the range that CloudFront compresses. If the Content-Length header is missing, CloudFront won’t compress the file.
Is there any way to enforce nginx to parse the whole file (and apply the SSI) before sending the headers and therefore including the Content-Length
as well? Or even better: Force Cloudfront to compress subsequent cache hits for which it obviously already knows the content length?