Cache doesn’t work with WP_REST_Request
-
Hi there,
Firstly, let me thank you for your very helpful plugin.
However, I am encountering an issue.
I have a page template (basically a front-end sitemap) that is listing all my products – which is a custom post type (not related to woocommerce).
In order to do so, I am using my custom API point /tree that is already listing all of my products the way I need to.I noticed that when my /tree has been flushed (code below).
add_filter('acf/save_post', function () { // Systematically flush /tree route since this route is retrieving every pages of the website Caching::get_instance()->delete_cache_by_endpoint('/wp-json/easyfichiers/v1/tree', Caching::FLUSH_LOOSE); [...] }, 10);
My /tree route doesn’t get cached when I am calling it through the WordPress built-in WP_Rest_Request class (code below).
public static function tree() { $request = new WP_REST_Request('GET', '/easyfichiers/v1/tree'); $response = rest_do_request($request); $server = rest_get_server(); $data = $server->response_to_data($response, false); return $data['response']; }
So my questions are :
– How to get my /tree route cached when calling it through WP_Rest_Request.
– I asked myself another question as I was writing this post : does WP_Rest_Request even uses WP Rest Cache to retrieve my custom route content ?Thanks in advance
Emmanuel
- The topic ‘Cache doesn’t work with WP_REST_Request’ is closed to new replies.