Problems with Gzip compression on Amazon CloudFront

amazon s3amazon-cloudfrontamazon-web-servicesgzip

I had a CloudFront distribution configured with S3 as an origin.

I have enabled "Compress Objects Automatically" as per Amazon guide. Waited for the distribution status to display "online" then invalidated all files.

My Response headers are:

Age:5
Connection:keep-alive
Content-Length:232359
Content-Type:application/javascript
Date:Sat, 03 Mar 2018 15:39:10 GMT
Last-Modified:Sat, 03 Mar 2018 15:37:32 GMT
Server:AmazonS3
Vary:Accept-Encoding
Via:1.1 4dbdc57755819d1a0ec1defc2630d677.cloudfront.net (CloudFront)
X-Amz-Cf-Id:6eHPWzOXv2J6kIvzuieoI9chtPBBvEvJFH9fb3yMwHvvcMZ4xsigCA==
X-Cache:Hit from cloudfront

Request Headers:

Accept:*/*
Accept-Encoding:gzip, deflate, br
Accept-Language:en-GB,en;q=0.9,en-US;q=0.8,pl;q=0.7,zh;q=0.6
Cache-Control:no-cache
Connection:keep-alive
Host:d2h5tcpn9r8alm.cloudfront.net
Pragma:no-cache
Referer:https://noru.co.uk/
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36

It has a "Content-length" and supported "Content-Type", what am I missing? I'm going mad here…

Since then I've created a new s3 bucket and new distribution going through the steps described above, but choosing a different bucket location (in case this is affecting is somehow),
Here are distribution general settings:

Delivery Method Web
Cookie Logging  Off
Distribution Status Deployed
Comment -
Price Class Use All Edge Locations (Best Performance)
AWS WAF Web ACL -
State   Enabled
Alternate Domain Names (CNAMEs) -
SSL Certificate Default CloudFront Certificate (*.cloudfront.net)
Domain Name d189ud9v76clu1.cloudfront.net
Custom SSL Client Support   -
Security Policy TLSv1
Supported HTTP Versions HTTP/2, HTTP/1.1, HTTP/1.0
IPv6    Enabled
Default Root Object -
Last Modified   2018-03-03 15:46 UTC
Log Bucket

And behaviours:
distribution behaviours

I still can't get gzip to work here is the new file:
http://d189ud9v76clu1.cloudfront.net/app.min.js

Best Answer

Does your request contain the necessary Accept-Encoding: gzip header?

Your headers look like curl output, which does not send that header by default.

You can test gzip encoding with curl via: curl -H "Accept-Encoding: gzip" https://example.com/asset.js"