Skip to content

Commit f45bbd3

Browse files
committed
Updates after review
1 parent e283160 commit f45bbd3

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

src/content/docs/cache/advanced-configuration/serve-tailored-content.mdx

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sidebar:
66
label: Serving tailored content
77
---
88

9-
import { DashButton } from "~/components";
9+
import { DashButton, APIRequest } from "~/components";
1010

1111
Content negotiation is the practice of serving different versions of a resource from a single URL, tailoring the experience to the end user. Common examples include delivering content in a specific language (`Accept-Language`), optimizing for a device (`User-Agent`), or serving modern image formats (`Accept`).
1212

@@ -56,25 +56,16 @@ To enable this feature, create a _variants rule_ using the API. This rule maps f
5656

5757
For example, the following API call tells Cloudflare that for `.jpeg` and `.jpg` files, your origin can serve `image/webp` and `image/avif` variants:
5858

59-
```bash
60-
# Replace $ZONE_ID and $CLOUDFLARE_API_TOKEN with your actual values
61-
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/cache/variants" \
62-
--request PATCH \
63-
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
64-
--header "Content-Type: application/json" \
65-
--json '{
66-
"value": {
67-
"jpeg": [
68-
"image/webp",
69-
"image/avif"
70-
],
71-
"jpg": [
72-
"image/webp",
73-
"image/avif"
74-
]
59+
<APIRequest
60+
path="/zones/{zone_id}/cache/variants"
61+
method="PATCH"
62+
json={{
63+
value: {
64+
jpeg: ["image/webp", "image/avif"],
65+
jpg: ["image/webp", "image/avif"]
7566
}
76-
}'
77-
```
67+
}}
68+
/>
7869

7970
After creating the rule, Cloudflare will create distinct cache entries for each image variant, improving performance for users with modern browsers.
8071

0 commit comments

Comments
 (0)