Skip to content

Commit ee51675

Browse files
Adds APIRequest component to Cache docs (#23531)
1 parent 80573b8 commit ee51675

File tree

4 files changed

+108
-85
lines changed

4 files changed

+108
-85
lines changed

src/content/docs/cache/advanced-configuration/cache-reserve.mdx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Cache Reserve
33
pcx_content_type: concept
44
---
55

6-
import { Render, TabItem, Tabs } from "~/components";
6+
import { Render, TabItem, Tabs, APIRequest } from "~/components";
77

88
Cache Reserve is a large, persistent data store [implemented on top of R2](/r2/). By pushing a single button in the dashboard, your website’s cacheable content will be written to Cache Reserve. In the same way that [Tiered Cache](/cache/how-to/tiered-cache/) builds a hierarchy of caches between your visitors and your origin, Cache Reserve serves as the ultimate [upper-tier cache](/cache/how-to/tiered-cache/) that will reserve storage space for your assets for as long as you want. This ensures that your content is served from cache longer, shielding your origin from unneeded egress fees.
99

@@ -201,10 +201,12 @@ Be aware that the deletion may take up to 24 hours to complete.
201201

202202
To delete Cache Reserve data via API use the following example requests. For more information, refer to the [API documentation](/api/resources/cache/subresources/cache_reserve/methods/clear/).
203203

204-
```bash title="Request 1: Get Cache Reserve status"
205-
curl https://api.cloudflare.com/client/v4/zones/{zone_id}/cache/cache_reserve \
206-
--header "Authorization: Bearer <API_TOKEN>"
207-
```
204+
**Request 1: Get Cache Reserve status**
205+
206+
<APIRequest
207+
path="/zones/{zone_id}/cache/cache_reserve"
208+
method="GET"
209+
/>
208210

209211
```json title="Response"
210212
{
@@ -221,11 +223,12 @@ curl https://api.cloudflare.com/client/v4/zones/{zone_id}/cache/cache_reserve \
221223

222224
If Cache Reserve is turned off, you can proceed to the Cache Reserve Clear operation.
223225

224-
```bash title="Request 2: Start Cache Reserve Clear"
225-
curl --request POST \
226-
https://api.cloudflare.com/client/v4/zones/{zone_id}/cache/cache_reserve_clear \
227-
--header "Authorization: Bearer <API_TOKEN>"
228-
```
226+
**Request 2: Start Cache Reserve Clear**
227+
228+
<APIRequest
229+
path="/zones/{zone_id}/cache/cache_reserve_clear"
230+
method="POST"
231+
/>
229232

230233
```json title="Response"
231234
{

src/content/docs/cache/advanced-configuration/vary-for-images.mdx

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pcx_content_type: concept
44

55
---
66

7-
import { Details, FeatureTable } from "~/components"
7+
import { Details, FeatureTable, APIRequest } from "~/components"
88

99
`Vary` is an HTTP response header that allows origins to serve variants of the same content that can be used depending on the browser sending the request.
1010

@@ -44,42 +44,43 @@ Vary for Images is enabled through Cloudflare’s API by creating a variants rul
4444

4545
### Create a variants rule
4646

47-
```bash
48-
curl --request PATCH \
49-
"https://api.cloudflare.com/client/v4/zones/{zone_id}/cache/variants" \
50-
--header "X-Auth-Email: <EMAIL>" \
51-
--header "X-Auth-Key: <API_KEY>" \
52-
--header "Content-Type: application/json" \
53-
--data '{"value":{"jpeg":["image/webp","image/avif"],"jpg":["image/webp","image/avif"]}}'
54-
```
47+
<APIRequest
48+
path="/zones/{zone_id}/cache/variants"
49+
method="PATCH"
50+
json={{
51+
value: {
52+
jpeg: ["image/webp", "image/avif"],
53+
jpg: ["image/webp", "image/avif"]
54+
}
55+
}}
56+
/>
5557

5658
### Modify to only allow WebP variants
5759

58-
```bash
59-
curl --request PATCH \
60-
"https://api.cloudflare.com/client/v4/zones/{zone_id}/cache/variants" \
61-
--header "X-Auth-Email: <EMAIL>" \
62-
--header "X-Auth-Key: <API_KEY>" \
63-
--header "Content-Type: application/json" \
64-
--data '{"value":{"jpeg":["image/webp"],"jpg":["image/webp"]}}'
65-
```
60+
<APIRequest
61+
path="/zones/{zone_id}/cache/variants"
62+
method="PATCH"
63+
json={{
64+
value: {
65+
jpeg: ["image/webp"],
66+
jpg: ["image/webp"]
67+
}
68+
}}
69+
/>
6670

6771
### Delete the rule
6872

69-
```bash
70-
curl --request DELETE \
71-
"https://api.cloudflare.com/client/v4/zones/{zone_id}/cache/variants" \
72-
--header "X-Auth-Email: <EMAIL>" \
73-
--header "X-Auth-Key: <API_KEY>"
74-
```
73+
<APIRequest
74+
path="/zones/{zone_id}/cache/variants"
75+
method="DELETE"
76+
/>
7577

7678
### Get the rule
7779

78-
```bash
79-
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/cache/variants" \
80-
--header "X-Auth-Email: <EMAIL>" \
81-
--header "X-Auth-Key: <API_KEY>"
82-
```
80+
<APIRequest
81+
path="/zones/{zone_id}/cache/variants"
82+
method="GET"
83+
/>
8384

8485
To learn more about purging varied images, refer to [Purge varied images](/cache/how-to/purge-cache/purge-varied-images/).
8586

src/content/docs/cache/how-to/purge-cache/purge-cache-key.mdx

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ sidebar:
66

77
---
88

9+
import { APIRequest } from "~/components";
10+
911
Instantly purge resources that use Cache Keys via the [Cloudflare API](/api/resources/cache/methods/purge/). If you use [Cloudflare's Purge by URL](/api/resources/cache/methods/purge/#purge-cached-content-by-url), include the headers and query strings that are in your custom Cache Key.
1012

1113
Currently, it is not possible to purge a URL stored through Cache API that uses a custom cache key set by a Worker. Instead, use a [custom key created by Cache Rules](/cache/how-to/cache-rules/settings/#cache-key). Alternatively, purge your assets using purge everything, purge by tag, purge by host or purge by prefix.
@@ -18,34 +20,55 @@ For a Cache Key based on device type, purge the asset by passing the `CF-Device-
1820

1921
Refer to the example API request below to instantly purge all mobile assets on the root webpage.
2022

21-
```bash
22-
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/purge_cache" \
23-
--header "X-Auth-Email: <EMAIL>" \
24-
--header "X-Auth-Key: <API_KEY>" \
25-
--header "Content-Type: application/json" \
26-
--data '{"files":[{"url":"http://my.website.com/","headers":{"CF-Device-Type":"mobile"}}]}'
27-
```
23+
<APIRequest
24+
path="/zones/{zone_id}/purge_cache"
25+
method="POST"
26+
json={{
27+
files: [
28+
{
29+
url: "http://my.website.com/",
30+
headers: {
31+
"CF-Device-Type": "mobile"
32+
}
33+
}
34+
]
35+
}}
36+
/>
2837

2938
## Purge by geo
3039

3140
Instantly purge resources for a location-based Cache Key by specifying the two-letter country code. Spain is used in the example below.
3241

33-
```bash
34-
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/purge_cache" \
35-
--header "X-Auth-Email: <EMAIL>" \
36-
--header "X-Auth-Key: <API_KEY>" \
37-
--header "Content-Type: application/json" \
38-
--data '{"files":[{"url":"http://my.website.com/", "headers":{"CF-IPCountry":"ES"}}]}'
39-
```
42+
<APIRequest
43+
path="/zones/{zone_id}/purge_cache"
44+
method="POST"
45+
json={{
46+
files: [
47+
{
48+
url: "http://my.website.com/",
49+
headers: {
50+
"CF-IPCountry": "ES"
51+
}
52+
}
53+
]
54+
}}
55+
/>
4056

4157
## Purge by language
4258

4359
For a Cache Key based on language, purge the asset by passing the `accept-language` header. Refer to the example API request below to instantly purge all assets in Chinese (PRC).
4460

45-
```bash
46-
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/purge_cache" \
47-
--header "X-Auth-Email: <EMAIL>" \
48-
--header "X-Auth-Key: <API_KEY>" \
49-
--header "Content-Type: application/json" \
50-
--data '{"files":[{"url":"http://my.website.com/", "headers":{"accept-language":"zh-CN"}}]}'
51-
```
61+
<APIRequest
62+
path="/zones/{zone_id}/purge_cache"
63+
method="POST"
64+
json={{
65+
files: [
66+
{
67+
url: "http://my.website.com/",
68+
headers: {
69+
"accept-language": "zh-CN"
70+
}
71+
}
72+
]
73+
}}
74+
/>

src/content/docs/cache/how-to/tiered-cache.mdx

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pcx_content_type: concept
44

55
---
66

7-
import { Details, FeatureTable } from "~/components"
7+
import { Details, FeatureTable, APIRequest } from "~/components";
88

99
Tiered Cache uses the size of Cloudflare’s network to reduce requests to customer origins by dramatically increasing cache hit ratios. With data centers around the world, Cloudflare caches content very close to end users. However, if a piece of content is not in cache, the Cloudflare edge data centers must contact the origin server to receive the cacheable content.
1010

@@ -77,44 +77,40 @@ You can enable Tiered Cache in the dashboard or via API.
7777

7878
To enable Tiered Cache via API use the following cURL example:
7979

80-
```bash
81-
curl --request PATCH \
82-
https://api.cloudflare.com/client/v4/zones/{zone_id}/argo/tiered_caching \
83-
--header "X-Auth-Email: <EMAIL>" \
84-
--header "X-Auth-Key: <API_KEY>" \
85-
--header 'Content-Type: application/json' \
86-
--data '{ "value": "on" }'
87-
```
80+
<APIRequest
81+
path="/zones/{zone_id}/argo/tiered_caching"
82+
method="PATCH"
83+
json={{
84+
value: "on"
85+
}}
86+
/>
8887

8988
You can also configure Tiered Cache Topology via API, for instance:
9089

9190

9291
<Details header="Enable Smart Tiered Cache">
9392

94-
```bash
95-
curl --request PATCH \
96-
https://api.cloudflare.com/client/v4/zones/{zone_id}/cache/tiered_cache_smart_topology_enable \
97-
--header "X-Auth-Email: <EMAIL>" \
98-
--header "X-Auth-Key: <API_KEY>" \
99-
--header "Content-Type: application/json" \
100-
--data '{ "value": "on" }'
101-
```
93+
<APIRequest
94+
path="/zones/{zone_id}/cache/tiered_cache_smart_topology_enable"
95+
method="PATCH"
96+
json={{
97+
value: "on"
98+
}}
99+
/>
102100

103101

104102
</Details>
105103

106104

107105
<Details header="Enable Regional Tiered Cache">
108106

109-
```bash
110-
curl --request PATCH \
111-
https://api.cloudflare.com/client/v4/zones/{zone_id}/cache/regional_tiered_cache \
112-
--header "X-Auth-Email: <EMAIL>" \
113-
--header "X-Auth-Key: <API_KEY>" \
114-
--header 'Content-Type: application/json' \
115-
--data '{ "value": "on" }'
116-
```
117-
107+
<APIRequest
108+
path="/zones/{zone_id}/cache/regional_tiered_cache"
109+
method="PATCH"
110+
json={{
111+
value: "on"
112+
}}
113+
/>
118114

119115
</Details>
120116

0 commit comments

Comments
 (0)