Skip to content

Commit 30f45fd

Browse files
committed
[Speed] Notes about the Content-Length header in responses
1 parent a65a29a commit 30f45fd

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/content/docs/speed/optimization/content/compression.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,15 @@ If you do not want a particular response from your origin to be encoded with Bro
151151
Cloudflare will take into consideration the `accept-encoding` header value in website visitors' requests when sending responses to those visitors. However, when requesting content from your origin server, Cloudflare will send a different `Accept-Encoding` header, supporting Brotli and Gzip compression.
152152
:::
153153

154+
### Content-Length header handling
155+
156+
When Cloudflare compresses a response, it may omit the `Content-Length` HTTP header to avoid delivering incorrect length information caused by dynamic transformations. To preserve the `Content-Length` header, add `cache-control: no-transform` to the origin server's response. This directive prevents Cloudflare from altering compression on responses, allowing the `Content-Length` header to pass through as-is. The `cache-control: no-transform` header must be set by the origin — it cannot be added by client requests.
157+
154158
---
155159

156160
<Render file="brotli-compression-warning" />
157161

158-
## Compression methods by plan
162+
## Compression methods by plan
159163

160164
### Between visitors and Cloudflare
161165

@@ -167,4 +171,4 @@ By default, Cloudflare uses the following compression methods for content delive
167171

168172
### Between Cloudflare and the origin server
169173

170-
On all plans, Cloudflare requests content from the origin server using the `accept-encoding: br, gzip` header. This means that Cloudflare asks the origin to send the content compressed using Brotli or Gzip, depending on which method the origin server supports.
174+
On all plans, Cloudflare requests content from the origin server using the `accept-encoding: br, gzip` header. This means that Cloudflare asks the origin to send the content compressed using Brotli or Gzip, depending on which method the origin server supports.

src/content/partials/speed/brotli-compression-warning.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
## Notes about end-to-end compression
66

7+
### Content recompression due to dynamic transformations
8+
79
Even when using the same compression algorithm end to end (between your origin server and Cloudflare, and between the Cloudflare global network and your website visitor), Cloudflare will need to decompress the response and compress it again if you enable any of the following settings for the request:
810

911
- [Automatic HTTPS Rewrites](/ssl/edge-certificates/additional-options/automatic-https-rewrites/)
@@ -20,3 +22,7 @@ To disable these settings for specific URI paths, create a [configuration rule](
2022
:::note
2123
Additionally, the [Replace insecure JS libraries](/waf/tools/replace-insecure-js-libraries/) setting also requires Cloudflare to decompress the response and compress it again. At this time, you cannot turn it off using Configuration Rules.
2224
:::
25+
26+
### Content-Length header
27+
28+
Cloudflare may remove the `Content-Length` HTTP header of responses delivered to website visitors. To ensure that the header is preserved, add a `cache-control: no-transform` HTTP header to the response at the origin server.

0 commit comments

Comments
 (0)