AWS AmazonCloudFront documentation change
Summary
Restructured documentation with updated configuration steps, added console-specific instructions, clarified compression behavior, removed browser-specific HTTPS/Brotli note, and added cache policy requirements for Brotli.
Security assessment
The removed note about Chrome/Firefox requiring HTTPS for Brotli could relate to secure communication, but there's no evidence this change addresses a vulnerability. Other changes focus on configuration clarity, performance, and operational behavior without introducing security context.
Diff
diff --git a/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.md b/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.md index 92b4a958d..0cd176794 100644 --- a//AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.md +++ b//AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.md @@ -9 +9 @@ Configure CloudFront to compress objectsHow CloudFront compression worksWhen Clo -You can use CloudFront to automatically compress 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. +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. Faster downloads can result in faster rendering of webpages for your viewers, especially for JavaScript and CSS files. In addition, 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. @@ -11 +11 @@ You can use CloudFront to automatically compress certain types of objects (files -CloudFront can compress objects using the Gzip and Brotli compression formats. When the viewer supports both formats, and both are present in the cache server that's reached, then CloudFront prefers Brotli. If only one compression format is present in the cache server, CloudFront returns it. +###### Topics @@ -13 +13 @@ CloudFront can compress objects using the Gzip and Brotli compression formats. W -If there are subsequent viewer requests for the same object, CloudFront returns the first cached version. For example, if a viewer requests a specific object that uses Gzip compression and the object is cached, and the viewer _accepts_ the Gzip format, subsequent requests to the same object will always return the Gzip version, even if the viewer accepts both Brotli and Gzip. + * Configure CloudFront to compress objects @@ -15 +15,7 @@ If there are subsequent viewer requests for the same object, CloudFront returns -###### Note + * How CloudFront compression works + + * When CloudFront compresses objects + + * File types that CloudFront compresses + + * ETag header conversion @@ -17 +22,0 @@ If there are subsequent viewer requests for the same object, CloudFront returns -The Chrome and Firefox web browsers support Brotli compression only when the request is sent using HTTPS. These browsers don't support Brotli with HTTP requests. @@ -19 +23,0 @@ The Chrome and Firefox web browsers support Brotli compression only when the req -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. @@ -21 +24,0 @@ When requested objects are compressed, downloads can be faster because the objec -Some custom origins can also compress objects. Your origin might be able to compress objects that CloudFront doesn’t compress (see File types that CloudFront compresses). If your origin returns a compressed object to CloudFront, CloudFront detects that the object is compressed based on the presence of a `Content-Encoding` header and doesn’t compress the object again. @@ -25 +28 @@ Some custom origins can also compress objects. Your origin might be able to comp -To configure CloudFront to compress objects, update the cache behavior that you want to serve the compressed objects by doing _**all**_ of the following: +To configure CloudFront to compress objects, update the cache behavior that you want to serve the compressed objects. @@ -27 +30 @@ To configure CloudFront to compress objects, update the cache behavior that you - 1. Make sure the **Compress objects automatically** setting is **Yes**. (In AWS CloudFormation or the CloudFront API, set `Compress` to `true`.) +###### To configure CloudFront to compress objects (console) @@ -29 +32 @@ To configure CloudFront to compress objects, update the cache behavior that you - 2. Use a [cache policy](./controlling-the-cache-key.html) to specify caching settings, and make sure the **Gzip** and **Brotli** settings are both enabled. (In AWS CloudFormation or the CloudFront API, set `EnableAcceptEncodingGzip` and `EnableAcceptEncodingBrotli` to `true`.) + 1. Sign in to the [CloudFront console](https://console.aws.amazon.com/cloudfront/v4/home). @@ -31 +34 @@ To configure CloudFront to compress objects, update the cache behavior that you - 3. Make sure that you set the TTL values in the cache policy to a value greater than zero. If you set the [Minimum TTL](./distribution-web-values-specify.html#DownloadDistValuesMinTTL) value to zero, caching of compressed content is disabled. + 2. Choose your distribution and then choose the **Behavior** to edit. @@ -32,0 +36 @@ To configure CloudFront to compress objects, update the cache behavior that you + 3. For the **Compress objects automatically** setting, choose **Yes**. @@ -33,0 +38 @@ To configure CloudFront to compress objects, update the cache behavior that you + 4. Use a [cache policy](./controlling-the-cache-key.html) to specify the caching settings, and enable both **Gzip** and **Brotli** compression formats. @@ -34,0 +40 @@ To configure CloudFront to compress objects, update the cache behavior that you + 5. Set the **TTL settings** in the cache policy to a value greater than zero. If you set the [Minimum TTL](./distribution-web-values-specify.html#DownloadDistValuesMinTTL) value to zero, CloudFront won't cache compressed content. @@ -36 +41,0 @@ To configure CloudFront to compress objects, update the cache behavior that you -To update a cache behavior, you can use any of the following tools: @@ -38 +42,0 @@ To update a cache behavior, you can use any of the following tools: - * The [CloudFront console](https://console.aws.amazon.com/cloudfront/v4/home) @@ -40 +43,0 @@ To update a cache behavior, you can use any of the following tools: - * [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_CloudFront.html) @@ -42 +45 @@ To update a cache behavior, you can use any of the following tools: - * The [AWS SDKs and command line tools](https://aws.amazon.com/getting-started/tools-sdks/) +###### Notes @@ -43,0 +47,3 @@ To update a cache behavior, you can use any of the following tools: + * You must use [cache policies](./controlling-the-cache-key.html) to use Brotli compression. Brotli doesn't support legacy cache settings. + + * To enable compression by using [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-distribution-cachebehavior.html) or the [CloudFront](https://docs.aws.amazon.com/cloudfront/latest/APIReference/Welcome.html) API, set the `Compress`, `EnableAcceptEncodingGzip`, `EnableAcceptEncodingBrotli` parameters to `true`. @@ -47 +52,0 @@ To update a cache behavior, you can use any of the following tools: -## How CloudFront compression works @@ -49 +54,3 @@ To update a cache behavior, you can use any of the following tools: -When you configure CloudFront to compress objects (see the previous section), here’s how it works: +To understand how CloudFront compresses objects, see the following section. + +## How CloudFront compression works @@ -51 +58 @@ When you configure CloudFront to compress objects (see the previous section), he - 1. A viewer requests an object. The viewer includes the `Accept-Encoding` HTTP header in the request, and the header value includes `gzip`, `br`, or both. This indicates that the viewer supports compressed objects. When the viewer supports both Gzip and Brotli, CloudFront prefers Brotli. + 1. A viewer requests an object. The viewer includes the `Accept-Encoding` HTTP header in the request, and the header value includes `gzip`, `br`, or both. This indicates that the viewer supports compressed objects. When the viewer supports both Gzip and Brotli, CloudFront uses Brotli. @@ -55 +62 @@ When you configure CloudFront to compress objects (see the previous section), he -The 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. +Chrome and Firefox web browsers support Brotli compression only when the request is sent using HTTPS. They don't support Brotli with HTTP requests. @@ -59 +66 @@ The Chrome and Firefox web browsers support Brotli compression only when the req - 3. If the compressed object is already in the cache, CloudFront sends it to the viewer and skips the remaining steps. + 3. Depending whether the compressed object is in the cache or not, CloudFront does one of the following: @@ -61 +68,3 @@ The Chrome and Firefox web browsers support Brotli compression only when the req -If the compressed object is not in the cache, CloudFront forwards the request to the origin. + * If the compressed object is already in the cache, CloudFront sends the object to the viewer and skips the remaining steps. + + * If the compressed object isn't in the cache, CloudFront forwards the request to the origin. @@ -67 +76,3 @@ If an uncompressed copy of the object is already in the cache, CloudFront might - 4. If the origin returns a compressed object, as indicated by the presence of a `Content-Encoding` header in the HTTP response, CloudFront sends the compressed object to the viewer, adds it to the cache, and skips the remaining step. CloudFront doesn’t compress the object again. + 4. If the origin returns a compressed object, (as indicated by the `Content-Encoding` header in the HTTP response), CloudFront sends the compressed object to the viewer, adds it to the cache, and skips the remaining steps. CloudFront doesn’t compress the object again. + + 5. If the origin returns an uncompressed object to CloudFront without the `Content-Encoding` header in the HTTP response, CloudFront then determines whether the object can be compressed. For more information, see When CloudFront compresses objects. @@ -69 +80 @@ If an uncompressed copy of the object is already in the cache, CloudFront might -If the origin returns an uncompressed object to CloudFront (there’s no `Content-Encoding` header in the HTTP response), CloudFront determines whether the object is compressible. For more information about how CloudFront determines whether an object is compressible, see the following section. + 6. If the object can be compressed, CloudFront compresses it, sends it to the viewer, and then adds it to the cache. @@ -71 +82 @@ If the origin returns an uncompressed object to CloudFront (there’s no `Conten - 5. If the object is compressible, CloudFront compresses it, sends it to the viewer, and adds it to the cache. (In rare cases, CloudFront might skip compression and send the uncompressed object to the viewer.) + 7. If there are subsequent viewer requests for the same object, CloudFront returns the first cached version. For example, if a viewer requests a specific cached object that uses Gzip compression, and the viewer _accepts_ the Gzip format, subsequent requests to the same object will always return the Gzip version, even if the viewer accepts both Brotli and Gzip. @@ -75,0 +87,2 @@ If the origin returns an uncompressed object to CloudFront (there’s no `Conten +Some custom origins can also compress objects. Your origin might be able to compress objects that CloudFront doesn’t compress. For more information, see File types that CloudFront compresses. + @@ -83 +96 @@ The following list provides more information about when CloudFront compresses ob -If a request to CloudFront uses HTTP 1.0, CloudFront removes the `Accept-Encoding` header and does not compress the object in the response. +If a request to CloudFront uses HTTP 1.0, CloudFront removes the `Accept-Encoding` header and doesn't compress the object in the response. @@ -88 +101 @@ If a request to CloudFront uses HTTP 1.0, CloudFront removes the `Accept-Encodin -If the `Accept-Encoding` header is missing from the viewer request, or if it doesn’t contain `gzip` or `br` as a value, CloudFront does not compress the object in the response. If the `Accept-Encoding` header includes additional values such as `deflate`, CloudFront removes them before forwarding the request to the origin. +If the `Accept-Encoding` header is missing from the viewer request, or if it doesn’t contain `gzip` or `br` as a value, CloudFront doesn't compress the object in the response. If the `Accept-Encoding` header includes additional values such as `deflate`, CloudFront removes them before forwarding the request to the origin. @@ -92,5 +104,0 @@ When CloudFront is configured to compress objects, it includes the `Accept-Encod -**Dynamic content** - - -CloudFront does not always compress dynamic content. Sometimes responses for dynamic content are compressed, and sometimes they are not. - @@ -100 +108 @@ CloudFront does not always compress dynamic content. Sometimes responses for dyn -CloudFront compresses objects when it gets them from the origin. When you configure CloudFront to compress objects, CloudFront doesn’t compress objects that are already cached in edge locations. In addition, when a cached object expires in an edge location and CloudFront forwards another request for the object to your origin, CloudFront doesn’t compress the object when your origin returns an HTTP status code 304, which means that the edge location already has the latest version of the object. If you want CloudFront to compress objects that are already cached in edge locations, you need to invalidate those objects. For more information, see [Invalidate files to remove content](./Invalidation.html). +CloudFront compresses objects when it gets them from the origin. When you configure CloudFront to compress objects, CloudFront doesn’t compress objects that are already cached in edge locations. In addition, when a cached object expires in an edge location and CloudFront forwards another request for the object to your origin, CloudFront doesn’t compress the object when your origin returns an HTTP status code 304. This means that the edge location already has the latest version of the object. If you want CloudFront to compress objects that are already cached in edge locations, you need to invalidate those objects. For more information, see [Invalidate files to remove content](./Invalidation.html). @@ -105 +113 @@ CloudFront compresses objects when it gets them from the origin. When you config -If you configure CloudFront to compress objects and the origin also compresses objects, the origin should include a `Content-Encoding` header, which indicates to CloudFront that the object is already compressed. When a response from an origin includes the `Content-Encoding` header, CloudFront does not compress the object, regardless of the header’s value. CloudFront sends the response to the viewer and caches the object in the edge location. +If you configure CloudFront to compress objects and the origin also compresses objects, the origin should include a `Content-Encoding` header. This header indicates to CloudFront that the object is already compressed. When a response from an origin includes the `Content-Encoding` header, CloudFront doesn't compress the object, regardless of the header’s value. CloudFront sends the response to the viewer and caches the object in the edge location. @@ -110 +118 @@ If you configure CloudFront to compress objects and the origin also compresses o -For a complete list of the file types that CloudFront compresses, see File types that CloudFront compresses. +For a complete list, see File types that CloudFront compresses. @@ -142 +150 @@ CloudFront skips compression** -CloudFront compresses objects on a best-effort basis. In rare cases, CloudFront skips compression. CloudFront makes this decision based on a variety of factors, including host capacity. If CloudFront skips compression for an object, it caches the uncompressed object and continues to serve it to viewers until the object expires, is evicted, or is invalidated. +CloudFront compresses objects on a best-effort basis. In rare cases, CloudFront skips compressing an object when CloudFront experiences high traffic load. CloudFront makes this decision based on a variety of factors, including host capacity. If CloudFront skips compression for an object, it caches the uncompressed object and continues to serve it to viewers until the object expires, is evicted, or is invalidated. @@ -246,0 +255,2 @@ If you configure CloudFront to compress objects, CloudFront only compresses obje +Show moreShow less + @@ -263 +273 @@ For more information, see the following pages in the MDN web docs: - * [`If-None-Match` HTTP header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-None-Match) + * [If-None-Match HTTP header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-None-Match)