Previous: , Up: Adding Removing Replacing Content   [Index]

Serving Compressed Files

You can configure CloudFront to automatically compress files of certain types and serve the compressed files when viewer requests include Accept-Encoding: gzip in the request header. When content is compressed, downloads are faster because the files are smaller—in some cases, less than a quarter the size of the original. Especially for JavaScript and CSS files, faster downloads translates into faster rendering of web pages for your users. In addition, because the cost of CloudFront data transfer is based on the total amount of data served, serving compressed files is less expensive than serving uncompressed files.

A viewer request must include ‘Accept-Encoding: gzip’ in the request header, or CloudFront won’t compress the requested file.

If you’re using a custom or Amazon S3 origin, you can configure your origin to compress files with or without CloudFront compression. Your origin can compress file types that CloudFront doesn’t compress.