A CloudFront distribution serves both video files (already-compressed MP4 and HLS) and text assets such as JavaScript and CSS. The goal is to reduce bandwidth on the compressible assets without touching video delivery. How should automatic compression be configured?
Show answer and explanation
Answer: B
CloudFront automatic compression applies gzip or Brotli only to requests that advertise an Accept-Encoding header, meet the compressible content-type list such as JavaScript and CSS, and pass the minimum file size. Enabling it on the text-asset behaviors therefore shrinks those responses at the edge, while the video behaviors, whose MP4 and HLS content is already compressed, never pay edge CPU to re-compress bytes that would not shrink meaningfully.
Per-behavior configuration is what lets the two content types be treated differently on one distribution.
Why the other options are wrong
- A. Compressing already-compressed video wastes edge processing time and can even enlarge the payload, so an aggressive global setting works against the video side of the distribution.
- C. CloudFront Functions operate on request and response headers and cannot re-compress a response body; manual compression at the edge is not a capability that exists.
- D. Origin-only compression means every miss returns already-compressed bytes, which is fine, but it also costs origin CPU on every generate; the edge setting achieves the same bandwidth savings with less origin load, and it keeps compression behavior bounded to the text assets.