Skip to content

Instantly share code, notes, and snippets.

@nowakpiotrek
Created September 18, 2016 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nowakpiotrek/1862e87161a66599a167544a1886b283 to your computer and use it in GitHub Desktop.
Save nowakpiotrek/1862e87161a66599a167544a1886b283 to your computer and use it in GitHub Desktop.
Clear Varnish and CloudFlare from CometCache plugin config.
<?php
$varnish_ip = VHP_VARNISH_IP;
$purge_url = 'http://'.$varnish_ip.'/blog/.*';
$result = wp_remote_request($purge_url, array(
'method' => 'PURGE',
'headers' => array(
'Host' => $_SERVER['HTTP_HOST'],
'X-Purge-Method' => 'regex',
)));
echo '<p>Also cleared Varnish cache.</p>';
$purge_url = 'https://api.cloudflare.com/client/v4/zones/' . CF_ZONE . '/purge_cache';
$result = wp_remote_request($purge_url, array(
'method' => 'DELETE',
'headers' => array(
'X-Auth-Email' => CF_EMAIL,
'X-Auth-Key' => CF_KEY,
'Content-Type' => 'application/json'
),
'body' => "{'purge_everything': true}"
));
echo '<p>Also cleared CloudFlare cache.</p>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment