-
-
Save nowakpiotrek/1862e87161a66599a167544a1886b283 to your computer and use it in GitHub Desktop.
Clear Varnish and CloudFlare from CometCache plugin config.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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