Support » Plugin: WP Fastest Cache » Cache Purge API

  • Resolved oliverjuwig

    (@oliverjuwig)


    Hello,

    first: I love this plugin.

    second: Is an API call available to purge the cache incl. minified CSS/JS? Yes, I have seen the automation rules, but I must coordinate it exactly with other actions on my site using a cron job.

    Best regards

    Oliver

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Emre Vona

    (@emrevona)

    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();
    
    Plugin Author Emre Vona

    (@emrevona)

    ok

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Cache Purge API’ is closed to new replies.