Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions src/content/docs/rules/reference/troubleshooting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ head:
- tag: title
content: Rules troubleshooting
description: Review common troubleshooting scenarios for Rules features.

---

import { Example, Render } from "~/components"
import { Example, Render } from "~/components";

## Interaction between Cloudflare challenges and Rules features

Expand All @@ -28,6 +27,12 @@ For example, define a compound expression for your rule using the `and` operator

If you are using [HTTP DCV](/ssl/edge-certificates/changing-dcv-method/methods/http/) and also have [Single Redirects](/rules/url-forwarding/single-redirects/) set up in your zone, consider excluding the `/.well-known/*` path from your rule to avoid DCV issues. For details and other resources refer to the [SSL/TLS documentation](/ssl/edge-certificates/changing-dcv-method/).

## Content-Length header removed from response

Cloudflare may remove the `Content-Length` header from responses delivered to website visitors. If the visitor must receive the `Content-Length` header, configure the origin server to include a `cache-control: no-transform` HTTP header in the response.

Alternatively, disable compression using a [compression rule](/rules/compression-rules/) and ensure that no Cloudflare settings are changing the response received from the origin server. For details on which products can change the response content, refer to [Notes about end-to-end compression](/speed/optimization/content/compression/#notes-about-end-to-end-compression).

## URL rewrites affect other Rules features executed later

If you rewrite a URI path using a [URL rewrite](/rules/transform/url-rewrite/), this may affect other Rules features executed later — such as [Origin Rules](/rules/origin-rules/) — if they include the URI path in their filter expression.
Expand All @@ -36,17 +41,17 @@ Consider the following origin rule configuration:

<Example>

* Rule expression: `http.host == "example.com" and starts_with(http.request.uri.path, "/downloads/")`
* **Host header** > **Rewrite to**: `assets.example.com`
- Rule expression: `http.host == "example.com" and starts_with(http.request.uri.path, "/downloads/")`
- **Host header** > **Rewrite to**: `assets.example.com`

</Example>

If you configure a new URL rewrite with the following configuration:

<Example>

* Rule expression: `http.host == "example.com" and starts_with(http.request.uri.path, "/downloads/")`
* **Path** > **Rewrite to** > **Dynamic**: `regex_replace(http.request.uri.path, "^/downloads/", "/")`
- Rule expression: `http.host == "example.com" and starts_with(http.request.uri.path, "/downloads/")`
- **Path** > **Rewrite to** > **Dynamic**: `regex_replace(http.request.uri.path, "^/downloads/", "/")`

</Example>

Expand All @@ -62,17 +67,17 @@ In the current example, you could use the `raw.http.request.uri.path` field in b

<Example>

* Rule expression: `http.host == "example.com" and starts_with(raw.http.request.uri.path, "/downloads/")`
* **Path** > **Rewrite to** > **Dynamic**: `regex_replace(raw.http.request.uri.path, "^/downloads/", "/")`
- Rule expression: `http.host == "example.com" and starts_with(raw.http.request.uri.path, "/downloads/")`
- **Path** > **Rewrite to** > **Dynamic**: `regex_replace(raw.http.request.uri.path, "^/downloads/", "/")`

</Example>

**Origin rule**

<Example>

* Rule expression: `http.host == "example.com" and starts_with(raw.http.request.uri.path, "/downloads/")`
* **Host header** > **Rewrite to**: `assets.example.com`
- Rule expression: `http.host == "example.com" and starts_with(raw.http.request.uri.path, "/downloads/")`
- **Host header** > **Rewrite to**: `assets.example.com`

</Example>

Expand Down
8 changes: 6 additions & 2 deletions src/content/docs/speed/optimization/content/compression.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ Smaller responses will not be compressed, regardless of their content type.

:::

### Content-Length header handling

When Cloudflare compresses a response sent to the website visitor, it may omit the `Content-Length` HTTP header to avoid delivering incorrect length information caused by dynamic transformations. To preserve the `Content-Length` header set by the origin server, 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 in client requests.

---

## Content compression from origin servers to the Cloudflare network
Expand Down Expand Up @@ -155,7 +159,7 @@ Cloudflare will take into consideration the `accept-encoding` header value in we

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

## Compression methods by plan
## Compression methods by plan

### Between visitors and Cloudflare

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

### Between Cloudflare and the origin server

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.
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.
6 changes: 6 additions & 0 deletions src/content/partials/speed/brotli-compression-warning.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## Notes about end-to-end compression

### Content recompression due to dynamic transformations

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:

- [Automatic HTTPS Rewrites](/ssl/edge-certificates/additional-options/automatic-https-rewrites/)
Expand All @@ -20,3 +22,7 @@ To disable these settings for specific URI paths, create a [configuration rule](
:::note
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.
:::

### Content-Length header

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.
Loading