Does not cache my custom endpoint
-
Hi,
Our Endpoint: https://tejtips.com/wp-json/tej/v1/events?tmz=Europe/Lisbon&idiom=pt&mod=2
(We also tested without query vars: https://tejtips.com/wp-json/tej/v1/events)Our route:
register_rest_route('tej/v1', 'events', array( 'methods' => 'GET', 'callback' => 'GetEvents', 'args' => array( 'tmz' => array( 'required' => false, 'validate_callback' => function ($param, $request, $key) { ... } ), 'idiom' => array( 'required' => false, 'validate_callback' => function ($param, $request, $key) { ... } ), 'mod' => array( 'required' => false, 'validate_callback' => function ($param, $request, $key) { ... } ) ), 'permission_callback' => '__return_true' ));
Our filter
function wprc_add_next_events_endpoint( $allowed_endpoints ) { if ( ! isset( $allowed_endpoints[ 'tej/v1' ] ) || ! in_array( 'events', $allowed_endpoints[ 'tej/v1' ] ) ) { $allowed_endpoints[ 'tej/v1' ][] = 'events'; } return $allowed_endpoints; } add_filter('wp_rest_cache/allowed_endpoints', 'wprc_add_next_events_endpoint', 10, 1);
In the backoffice, in the “Endpoint API Caches” tab, our endpoint does not appear and we did not notice any improvements in behavior (response time reduction, for example).
We verify that the route is added to the $allowed_endpoints looking something like:"tej/v1":[ "events" ]
It looks good to us but we never have the desired behavior…
Can you help?
Thanks!
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘Does not cache my custom endpoint’ is closed to new replies.