Can you look at the following tutorial please?
https://www.wpfastestcache.com/features/clear-cache-via-url/
If this feature is useful for you, you need to download the following version of wp fastest cache to use this feature because I did not release new version yet.
https://downloads.wordpress.org/plugin/wp-fastest-cache.zip
Hi,
thanks for your fast reply. I looked at your tutorial and I also looked at the code. In the end, I ended up with a somewhat different solution, which I automated using the Plugin “WP Crontrol”. The reason for that is, that I must purge the Autoptimize Cache at the same time.
<?php
function purge_cache() {
if ($_GET['token'] == PURGE_CACHE_TOKEN) {
if (class_exists('autoptimizeCache') && class_exists('WPFastestCache')) {
$wpfc = $GLOBALS["wp_fastest_cache"];
$wpfc->deleteCache(true);
autoptimizeCache::clearall();
$wpfc->deleteCache(true);
echo 'Cache cleared...';
} else {
echo 'Invalid configuration...';
}
} else {
echo 'Access denied...';
}
}
add_action('parse_request', 'my_custom_url_handler');
function my_custom_url_handler() {
if (substr($_SERVER["REQUEST_URI"], 0, 12) == '/purge-cache') {
purge_cache();
exit();
}
}
The function purge_cache can be called using ‘http://mydomain.com/purge-cache?token=xyz’ where xyz equals the special security token constant. The code for the WP Crontrol entry looks like this:
$_GET['token'] = PURGE_CACHE_TOKEN;
purge_cache();