is It possible to determine whether to maintain this cache in my api code
-
Hi, thank you for your plugin, it is very useful, I can cache my custom api through this following method, but now I have a need to determine whether to cache this api(wp/v2/getproduct) for one request time. Because once this api triggers certain conditions, I cannot cache this time api cache. Is there a method to achieve it in my custom api code?
function wprc_add_acf_posts_endpoint($allowed_endpoints) { if (!isset($allowed_endpoints['wp/v2']) || !in_array('getcontextualbundle', $allowed_endpoints['wp/v2'])) { $allowed_endpoints['wp/v2'][] = 'getproduct'; } return $allowed_endpoints; } //determine_cache_object_type function wprc_determine_object_type($object_type, $cache_key, $data, $uri) { if ($object_type !== 'unknown') { return $object_type; } if (strpos($uri, 'wp/v2/getproduct')) { $object_type = 'product'; } return $object_type; } add_filter('wp_rest_cache/allowed_endpoints', 'wprc_add_acf_posts_endpoint', 10, 1); /*** * * @description: my custom api */ function getproduct() { if(true) { How to not cache this access api? } }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘is It possible to determine whether to maintain this cache in my api code’ is closed to new replies.