Purge cache: Custom purge not working for 48 hours

We haven’t been able to purge cache per URL the last 48 hours.

We have tried to purge:

  • Via API (curl)
  • Dashboard: Custom Purge

Both unsuccessful.

Everything worked fine 3 days ago and we haven’t changed any settings or configurations since then.

I can not reproduce this.

Please post your actual API request and response, straight from the terminal window, minus the API Token/Key/Email address.

Then wait thirty seconds, and do this, then post the command and response straight from the terminal window:

curl -svo /dev/null FULL_URL_THAT_YOU_PURGED

Do not obfuscate anything from the curl command above.

I will not post the specific URL/domain here, but i can send it to you directly. Servers are placed in Denmark.

Custom Purge has been working for 6 years (except the last 3 days).

This is what i do:

  1. I log in to dash.cloudflare.com
  2. I go to “Cashing”
  3. I go to “Configuration”
  4. I click “Custom Purge”
  5. I paste the URL of the site i want to purge cache
  6. I click on “Purge”

I wait 30 seconds. The URL has not been purged.
I wait 1 minute. The URL has not been purged.
I wait 30 minutes. The URL has not been purged.
I wait 8 hours. The URL has not been purged.

My curl/API method is not the problem. It has been working for 6 years (except the last 3 days). But here you go (in PHP):

$email = ‘xxx’;
$key = ‘xxx’;
$zone = ‘xxx’;
$url = ‘xxx’;
$json = json_encode(array(‘files’=>$url));

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ‘https://api.cloudflare.com/client/v4/zones/'.$zone.'/purge_cache’);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, ‘DELETE’);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Auth-Email: '.$email,'X-Auth-Key: '.$key,‘Content-Type: application/json’));
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$result = curl_exec($ch);

This is not something we can solve if we can not reproduce the problem, or even see evidence of a problem.

I picked three cached URLs at random and purged them successfully via Postman:

Best to open a ticket so you can share your information with Support.

This has not solved the problem. The problem still exists.

How do i open a ticket? (Free plan)

The same error, ignored for 4 days already… On a free plan, but bought Page Rules and APO

1 Like

Experiencing the exact same issue.

Weirdly enough it works with Postman, but not with PHP via curl, even though response returns success.

The only thing I can think of its because its being sent from the same domain… Maybe it only works outside of domain IDK.

I know it isn’t working because a few images were updated and after purging their cache via the API it still displays the old ones, even with CTRL+F5.

I’ve lost an entire day playing with PHP’s curl options and got nowhere. Event tried https://github.com/cloudflare/cloudflare-php and it returned success alright, but images were the same, their cache wasn’t purged.

Here’s the implementation:

// $files is something like [`'https://domain.tld/image/1-100x100.jpg`', '`https://domain.tld/image/1-200x200.jpg`']

$ch = curl_init();

$chunked_files = array_chunk($files, 30);
foreach ($chunked_files as $index => $files) {

    $data = ['files' => $files,];
    $request_body = json_encode($data);

    curl_setopt_array($ch, [
        CURLOPT_URL => 'https://api.cloudflare.com/client/v4/zones/' . $this->cloudflare['zoneID'] . '/purge_cache',
        CURLOPT_HTTPHEADER => [
            'Content-Type: application/json',
            'Authorization: Bearer ' . $this->cloudflare['token'],
            'Cache-Control: no-cache',
        ],
        CURLOPT_POST => 1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => $request_body,
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_HEADER => 1,
        CURLINFO_HEADER_OUT => 1,
    ]);

    $response = curl_exec($ch);
    $info = curl_getinfo($ch);
    
    $header = substr($response, 0, $info['header_size']);
    $body = substr($response, $info['header_size']);
    $response = $body;

    // response is something like  {"success":true,"errors":[],"messages":[],"result":{"id":"censored"}}
    
    $json = json_decode($response, true);
    
}

Anyone had any luck ?

I am facing exact same issue. Were you able to resolve your problem?

In my case, purge call is working for few files and not working for other.
Following is the structure of my call.

curl -X POST "https://api.cloudflare.com/client/v4/zones/<zoneID>/purge_cache" 
 -H "X-Auth-Email: <email>”  
-H "X-Auth-Key: <Authkey>” 
-H "Content-Type: application/json" 
 --data '{"files":[
 "https:\/\/<server domain>\/Server2\/BI5-1-66-Android\/data\/Configs\/Settings.plist", 
"https:\/\/<server domain>\/Server2\/BI51-1-66\/data\/Configs\/Settings.plist", 
"https:\/\/<server domain>\/Server2\/BI-Rizwan\/data\/Configs\/Settings.plist"
 ]}'

I always get success reply. But only file in folder “BI5-1-66-Android” get purged successfully.
{“success”:true,“errors”:,“messages”:,“result”:{“id”:“”}}

Considering, one file get purged successfully all the time, I am sure my purge call and params and are 100% correct. Moreover, if I make same call from my local machine terminal or from postman, every things work fine and all three files get purged.

@sdayman Can you say anything about possible reason for my issue?