Support » Plugin: WP REST Cache » Function to call to flush WP REST cache

  • Resolved forgetme


    Is there a function that I can call through a script to clear the wp rest cache?

    Below is an example of what I’m doing with the script to call the function that clears WP Rocket’s cache for my site either through SSH or through an HTTPS call. I call this any time a commit is pushed via git to ensure that the latest changes from dev -> prod are working correctly and the cache isn’t serving outdated content. I’d like to make sure the same thing happens with my wp rest cache.

    if ( function_exists( 'rocket_clean_domain' ) ) {
    	echo ( "Cache Flushed <br><br>" );
    	error_log( "Cache Flushed \n" );
    • This topic was modified 1 year, 3 months ago by forgetme.
Viewing 1 replies (of 1 total)
  • Plugin Author Richard Korthuis


    Hi @forgetme

    Thank you for using our plugin!

    There are two ways you could do this. The first depends on whether you have WP CLI installed. If so you could use the WP CLI command wp wp-rest-cache flush. If you don’t there is a second method to achieve what you want, you could call \WP_Rest_Cache_Plugin\Includes\Caching\Caching::get_instance()->delete_all_caches()

Viewing 1 replies (of 1 total)
  • The topic ‘Function to call to flush WP REST cache’ is closed to new replies.