I am trying to deliver compressed CSS and JS files to my web application. Files are hosted on S3 with a Cloudfront distribution in front of the S3 source to provide caching. I am having trouble getting these files in the browser, both compressed and with corresponding headers related to the cache, so that the browser can also cache.
I have a cloud distribution with S3 as Origin for delivering JS and CSS files for my web application. At first I created CloudFront to compress files, but it did not send headers Cache-Controlor ETagin response.
Since I also wanted to use the browser cache, I thought about saving gzipped files in S3 with Cache-Controland headers attached Content-Encoding. I did it, and began to return CloudFront headers Cache-Controland ETagin response, but did not return the header Content-Encoding: gzipin the response (which I found in the S3 in the metadata file). Since the response does not have this header, the browser does not know to unlock the response and ends with an unreadable file.
I also tried setting up a comment response feed for the viewer to add a title Content-Encoding, but this is forbidden (see AWS docs ) and results in a LambdaValidationError.
Is there something that I am missing here that will allow files to do this in a compressed browser, And still allow the headers Cache-Controland ETagdo it using the browser?
Any help would be greatly appreciated!
source
share