Stuborg
Stuborg

Reputation: 121

GZIP not working in Amazon Cloudfront

I am trying to load compressed javascript and css files on my page. My files are in the amazon s3 server and I have configured the Cloudfront Distribution to Compress Objects Automatically. Even after setting up the Cloudfront Distribution, I am still getting the uncompressed files on my page instead of the compressed ones that Cloudfront should be loading.

enter image description here

Files in my Amazon s3 server

https://s3.us-east-2.amazonaws.com/02242017-bucket1/animate.css

https://s3.us-east-2.amazonaws.com/02242017-bucket1/jssor.js

My Request Header reads

Accept:*/*
Accept-Encoding:gzip, deflate, sdch, br
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Host:s3.us-east-2.amazonaws.com
Referer:http://test.sitepm.com/simplewebcontent/710/1/peterspage1
User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36

My Response Header is

Accept-Ranges:bytes
Content-Length:58701
Content-Type:application/javascript
Date:Tue, 28 Feb 2017 10:30:41 GMT
ETag:"be74d5befb57a55bcf71d5af775f8dfb"
Last-Modified:Fri, 24 Feb 2017 05:06:32 GMT
Server:AmazonS3
x-amz-id-2:ioAxulBZpyxcqCAdvQ47uCuA2zwvh9wrUXA6yyPdL0dt9suwZWSHc8E0hrxte+cBd8kpQt4IYEI=
x-amz-request-id:1FA844B6044B1E2A

My Cloudfront Origin Settings enter image description here

Can anyone tell me what I am missing here...

Upvotes: 4

Views: 3636

Answers (1)

Michael - sqlbot
Michael - sqlbot

Reputation: 179414

You may have configured a CloudFront distribution, but based on these request and response headers, you're not actually requesting the objects through CloudFront.

Request:

Host:s3.us-east-2.amazonaws.com

This is obviously not a CloudFront hostname, e.g. dxxxexample.cloudfront.net, and not a hostname from a custom domain... You're requesting this directly from S3.

Response:

If this request had been processed by CloudFront, the response headers Via and X-Cache and X-Amz-Cf-Id would be present, but they are not.

Upvotes: 4

Related Questions