• Resolved archi76

    (@archi76)


    function add_custom_endpoint_cache( $allowed_endpoints ) {
    if ( ! isset( $allowed_endpoints[ ‘api-json’ ] ) ) {
    $allowed_endpoints[ ‘api-json’ ][] = ”;
    }
    return $allowed_endpoints;
    }

    I am caching all my custom rest APIs but I need some certain APIs not to be cached
    example : /wp-json/api-json/travels , /wp-json/api-json/customers

    let’s say I wanna cache all the other APIs except those

Viewing 1 replies (of 1 total)
  • Plugin Author Richard Korthuis

    (@rockfire)

    Hi @archi76

    Thank you for using our plugin!

    At this point we do not have a filter to register disallowed endpoints. So the only way to do so right now is to register all allowed endpoints:

    $allowed_endpoints['api-json'][] = 'trips';
    $allowed_endpoints['api-json'][] = 'trains';
    ...

    and leave out the endpoint you do not want cached. Having said that we might need to consider adding a filter for disallowed endpoints, but that won’t be released very soon.

Viewing 1 replies (of 1 total)
  • The topic ‘How to avoid caching of certain routes under main namespace’ is closed to new replies.