How can I search for which domains are using Cache Reserve?

Hi.
I received an invoice for Cache Reserve usage.
** I am wondering if I can search for which domain(s) are using Cache Reserve in my account?

Thank you,
Brent :sunglasses:

You can use the API to check whether Cache Reserve is active for any domain:
https://developers.cloudflare.com/api/operations/zone-cache-settings-get-cache-reserve-setting

A little Script that loops through your domains should quickly find the culprit.

1 Like

Hey Laudian,

Thank you - that sounds fairly easy.
However I haven’t written a script since I used to write batch files for DOS.
So unfortunately I don’t think this is in my skill set.

Does anyone already have such a script ready to go?

Brent :sunglasses:

You can try this Python script for Linux:

#!/usr/bin/python3
import os, json

bearer = YOUR_API_TOKEN

stream = os.popen(f"""curl -s --request GET \
  --url https://api.cloudflare.com/client/v4/zones \
  --header 'Authorization: Bearer {bearer}' \
  --header 'Content-Type: application/json'""")
  
zones = json.loads(stream.read())["result"]

for zone in zones:
    id = zone["id"]
    name = zone["name"]
    
    stream = os.popen(f"""curl -s --request GET \
  --url https://api.cloudflare.com/client/v4/zones/{id}/cache/cache_reserve \
  --header 'Authorization: Bearer {bearer}' \
  --header 'Content-Type: application/json'""")

    output = json.loads(stream.read())
    
    try:
        reserve_status = output["result"]["value"]
        print(name + ": " + reserve_status)
    except:
        print(name + ": " + "Cache Reserve not available for this domain")

Replace YOUR_API_TOKEN with a token that you create. I used Read all resources for the token, though you don’t need all of those obviously.

I’m afraid I can’t test if this is working because Cache Reserve is not available on my account

Thank you Laudian,
There are errors in the script, but I can’t fix them.
It’s OK, I will just look at each domain, and keep track manually.

Cheers,
Brent :sunglasses:

What errors?

It doesn’t matter - I don’t want to bother you any further.
I went through my domains manually and found them all.
I appreciate your time very much.
Have a great weekend!
Brent :sunglasses:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.