Confusing documentation on purge API

Re this https://api.cloudflare.com/#zone-purge-files-by-url

curl -X POST "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/purge_cache" \
         -H "X-Auth-Email: [email protected]" \
         -H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
         -H "Content-Type: application/json" \
         --data '{"files":["http://www.example.com/css/styles.css",{"url":"http://www.example.com/cat_picture.jpg","headers":{"Origin":"https://www.cloudflare.com","CF-IPCountry":"US","CF-Device-Type":"desktop"}}]}

What is “files” vs “url” in this?

The file URL is http://www.example.com/css/styles.css, so whats the url field of http://www.example.com/cat_picture.jpg

So confusing.


First I tried to purge a particular resource as follows:

{
"files":["<some cached URL here>"
]
}

This returned success:true, but there was still a cache HIT. So this actually didnt work.

Next I tried with:

{
"files":["<some cached URL here>",
  {
      "headers": {
      "Origin": "https://www<domain>"
      }
  }
]
}

This gave an error: “message”: “Request must contain one of “purge_everything”, “files”, “tags”, “hosts” or “prefixes””

Finally I tried with:

{
"files":["<some cached URL here>",
  {
      "url": "<some cached URL here>",
      "headers": {
      "Origin": "https://www<domain>"
      }
  }
]
}

This returned success:true, and resulted in a cache MISS (yah!).

So the Q is, whats the difference between files and url?

File is the actual resource that sits in the cache. URL is the way it’s identified. Other purge methods let Enterprise Plan users purge that file using a different identifier such as tags, hostname, or prefix (sort of like a wildcard). I think the example makes it overly complicated. I believe this is all you need:

Aiiii. I see that that my post above crapofied the 3rd part of my post after “Finally I tried with:” since I’d not marked it as code. Corrected now.

I dont think so. As you can see above, my first attempt was exactly this.