Purge Cache by URLs false positive results

Hi Everyone,

I’m experiencing an annoying issue where the cache purge API isn’t actually purging anything from a remote machine.

As part of our CI/CD process, we aim to purge the CDN cache. Therefore, I have created a container that receives the zone_id, api_token, and a list of URLs to purge as input.

Local tests passed just fine. I received a 200 success response, indicating we are good to go with integrating it into our CD pipeline. However, the issue arises when the CD pipeline runs (with the same code, values, and secrets, even hardcoded); it doesn’t actually purge the cache. I’m testing the cache purge with this command:

while true; do curl -I -H "Cache-Control: no-cache" "https://mydns.com"; sleep 5; done

and I’m looking for the cf-cache-status/age.

I have reviewed all our caching configurations, but I still can’t understand why the cache is not being purged globally.

Just adding here more information,

The result of the calls to the api endpoint of purge_cache is again 200 with result success.

That’s not a false positive. The call to purge went out successfully. Whether or not the cache key you think you asked to be purged is out there is another issue.

Cloudflare caches 404s, and you can purge those. So, yes, Cloudflare will purge cache keys that don’t actually exist, but could exist.

The issue you need to solve is what does your request to the origin actually look like.

Also, your curl command doesn’t need the cache-control header, and you shouldn’t be doing HEAD requests. It should be an organic curl -svo /dev/null. Something like this works well:

curl -svo /dev/null https://example.com/image.jpg 2>&1 | egrep "< cf-cache-status|< age"

1 Like


I can’t really explain why the same ongoing request doesn’t end with the same result.

same body.
same headers.
same credentials.

The only thing that is not the same is the location from the request is sent from.

1 from a mac machine - at the middle east.

the second from a kubernetes located at us-east-1 (north virginia).

This is my current caching rulesets. and this is my actual cache purge

curl --request POST \
  --url https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE_ID/purge_cache \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \
  --data "{

Just tried form another machine in AWS and im getting same result of OKAY 200, but still no cache purge.
Sending the same request from my machine works like a charm.