Custom REST Endpoint | WordPress.org

[ad_1]

hey !
I’m having a cache with the REST API.
Everything is working as expected, but the moment I change any value it takes up to 30sec / 1 min.

Try with set up headers,etc, but ain’t workin.

This is video might hlink

This is the code that I’m running.

add_action('rest_api_init', 'get_wp_page_fn2' );

function get_wp_page_fn2(){
    register_rest_route( '/wp/v2/tf_api/' ,'get_wp_page2', 
        array(
            'methods'  =>'GET',
            'callback' => 'get_wp_page_callback2',
        ) 
    );
}

function get_wp_page_callback2( $request) {
    $permalink = $request['permalink'];

    $data = array(
        $permalink,
        'is not updating', 
        get_template_directory_uri().'/home.112312323.js',
        'maybe not'
    );
    // Create the response object
    $response = new WP_REST_Response( $data );
    $response->header( 'Pragma', 'no-cache' );
    $response->header( 'Cache-Control', 'no-store, no-cache, must-revalidate' );
    $response->header( 'Expires',gmdate( 'D, d M Y H:i:s \G\M\T', time() )); 
    $response->header( 'Last-Modified',gmdate( 'D, d M Y H:i:s \G\M\T', time() )); 
    wp_send_json($response);
}

Please! I need help on this!

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer