Sunday, March 27, 2022

AWS CF compression


 

AWS CloudFront (CF) automatically compresses certain types of objects (files) and serve the compressed objects when viewers (web browsers or other clients) support them. Viewers indicate their support for compressed objects with the Accept-Encoding HTTP header. CloudFront can compress objects using the Gzip and Brotli compression formats. When the viewer supports both formats, CloudFront prefers Brotli.

Chrome and Firefox web browsers support Brotli compression only when the request is sent using HTTPS. These browsers do not support Brotli with HTTP requests.

When requested objects are compressed, downloads can be faster because the objects are smaller—in some cases, less than a quarter the size of the original. Especially for JavaScript and CSS files, faster downloads can result in faster rendering of webpages for your users. In addition, because the cost of CloudFront data transfer is based on the total amount of data served, serving compressed objects can be less expensive than serving them uncompressed.

CloudFront only compresses objects that have one of the following values in the Content-Type response header:

  1. application/dash+xml
  2. application/eot
  3. application/font
  4. application/font-sfnt
  5. application/javascript
  6. application/json
  7. application/opentype
  8. application/otf
  9. application/pkcs7-mime
  10. application/protobuf
  11. application/rss+xml
  12. application/truetype
  13. application/ttf
  14. application/vnd.apple.mpegurl
  15. application/vnd.mapbox-vector-tile
  16. application/vnd.ms-fontobject
  17. application/xhtml+xml
  18. application/xml
  19. application/x-font-opentype
  20. application/x-font-truetype
  21. application/x-font-ttf
  22. application/x-httpd-cgi
  23. application/x-javascript
  24. application/x-mpegurl
  25. application/x-opentype
  26. application/x-otf
  27. application/x-perl
  28. application/x-ttf
  29. font/eot
  30. font/opentype
  31. font/otf
  32. font/ttf
  33. image/svg+xml
  34. text/css
  35. text/csv
  36. text/html
  37. text/javascript
  38. text/js
  39. text/plain
  40. text/richtext
  41. text/tab-separated-values
  42. text/xml
  43. text/x-component
  44. text/x-java-source
  45. text/x-script
  46. vnd.apple.mpegurl

Ultimately, I realize a significant performance improvement on leveraging AWS CF compression.

No comments:

Post a Comment