• Resolved diplatis

    (@diplatis)


    Hi,

    I want to purge the page cache through a JSON API request. I think I may have to register a custom endpoint but I don’t know abou the callback (maybe w3tc_pgcache_flush) and how to make the authentication. Is something like that ok?

    add_action( 'rest_api_init', 'register_flush_cache_route' );
     
    function register_flush_cache_route() {
       register_rest_route( 'wp/v2', 'flushpagecache', array(
           'methods'  => POST,
           'callback' => 'w3tc_pgcache_flush',
    	   'permission_callback' => function($request){
    			return is_user_logged_in();}
       ) );
    }
    • This topic was modified 6 years, 7 months ago by diplatis.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Empty caches through WP JSON API’ is closed to new replies.