@@ -10,10 +10,10 @@ To purge zone versions via the Cloudflare API, follow these steps:
1010
1111## Step 1: Retrieve the environment ID
1212
13- First, retrieve your zone's environment ID using the following API request :
13+ First, retrieve your zone's environment ID by sending a request to the following API endpoint :
1414
1515``` bash
16- https://api.cloudflare.com/client/v4/zones/< zone-tag > /environments | jq .
16+ https://api.cloudflare.com/client/v4/zones/< zone_id > /environments
1717```
1818
1919This API call will return a JSON response similar to the example below:
@@ -24,33 +24,33 @@ This API call will return a JSON response similar to the example below:
2424 "environments" : [
2525 {
2626 "name" : " Production" ,
27- "ref" : " 40bebe5d89b34840a573f51834a54006 " ,
27+ "ref" : " 12abcd3e45f678940a573f51834a54 " ,
2828 "version" : 0 ,
29- "expression" : " (cf.zone.name eq \" jfowler.theburritobot .com\" )" ,
29+ "expression" : " (cf.zone.name eq \" example .com\" )" ,
3030 "locked_on_deployment" : false ,
3131 "position" : {
32- "before" : " 53278ccfd7564fa69172f19b43c8b8a9 "
32+ "before" : " 5d41402abc4b2a76b9719d911017c "
3333 }
3434 },
3535 {
3636 "name" : " Staging" ,
37- "ref" : " 53278ccfd7564fa69172f19b43c8b8a9 " ,
37+ "ref" : " 5d41402abc4b2a76b9719d911017c " ,
3838 "version" : 0 ,
39- "expression" : " ((cf.edge.server_ip in {162.159.133.39 162.159.134.39 })) and (cf.zone.name eq \" jfowler.theburritobot .com\" )" ,
39+ "expression" : " ((cf.edge.server_ip in {1.2.3.4 5.6.7.8 })) and (cf.zone.name eq \" example .com\" )" ,
4040 "locked_on_deployment" : false ,
4141 "position" : {
42- "before" : " 2f85286bafdf439f95fae39c4bdd80ac " ,
43- "after" : " 40bebe5d89b34840a573f51834a54006 "
42+ "before" : " 49f0bad299687c62334182178bfd " ,
43+ "after" : " 12abcd3e45f678940a573f51834a54 "
4444 }
4545 },
4646 {
4747 "name" : " Development" ,
48- "ref" : " 2f85286bafdf439f95fae39c4bdd80ac " ,
48+ "ref" : " 49f0bad299687c62334182178bfd " ,
4949 "version" : 0 ,
50- "expression" : " ((any(http.request.cookies[\" development\" ][*] eq \" true\" ))) and (cf.zone.name eq \" jfowler.theburritobot .com\" )" ,
50+ "expression" : " ((any(http.request.cookies[\" development\" ][*] eq \" true\" ))) and (cf.zone.name eq \" example .com\" )" ,
5151 "locked_on_deployment" : false ,
5252 "position" : {
53- "after" : " 53278ccfd7564fa69172f19b43c8b8a9 "
53+ "after" : " 5d41402abc4b2a76b9719d911017c "
5454 }
5555 }
5656 ]
@@ -61,24 +61,30 @@ This API call will return a JSON response similar to the example below:
6161}
6262```
6363
64- In this particular example, we have three environments: production, staging and development . You can find the environment ID in the ` ref ` field.
64+ In this particular example, we have three environments: Production, Staging and Development . You can find the environment ID in the ` ref ` field.
6565
6666## Step 2: Purge cache per environment
6767
68- To purge the production environmet, use the general cache purge endpoint:
68+ To purge the Production environmet, use the general cache purge endpoint:
6969
7070``` bash
71- https://api.cloudflare.com/client/v4/zones/< zone-tag > /purge_cache/
71+ https://api.cloudflare.com/client/v4/zones/< zone_id > /purge_cache/
7272```
7373
74- To purge the staging environment, use the following request:
74+ To purge non-production environments, you must use a new ` purge_cache ` endpoint and specify the environment you would like to purge.
75+
76+ To purge the Staging environment from the example above, send a request to the following endpoint:
7577
7678``` bash
77- https://api.cloudflare.com/client/v4/zones/< zone-tag > /environments/53278ccfd7564fa69172f19b43c8b8a9 /purge_cache/
79+ https://api.cloudflare.com/client/v4/zones/< zone_id > /environments/5d41402abc4b2a76b9719d911017c /purge_cache/
7880```
7981
80- To purge the development environment, use the following request :
82+ To purge the Development environment from the example above, send a request to the following endpoint :
8183
8284``` bash
83- https://api.cloudflare.com/client/v4/zones/< zone-tag> /environments/2f85286bafdf439f95fae39c4bdd80ac/purge_cache/
84- ```
85+ https://api.cloudflare.com/client/v4/zones/< zone_id> /environments/49f0bad299687c62334182178bfd/purge_cache/
86+ ```
87+
88+ :::note
89+ When purging everything for a non-production cache environment, all files for that specific cache environment will be purged. However, when purging everything for the production environment, all files will be purged across all environments.
90+ :::
0 commit comments