Hi @ahmadegbaria000
Thank you for using our plugin!
All you have to do is enable cache regeneration in the plugin settings 🙂
If you go to Settings > WP REST Cache and check the “Enable cache regeneration” checkbox a cron job will be added to regenerate expired or flushed caches. You can also change the regeneration interval and the number of caches to regenerate per interval. The interval and the number of caches depends on your servers capacity, so it is set at a low value but most servers can handle more than that.
Excuse me
If timeout 30 min
So i want to set Regeneration interval to 30 min, right?
Max number regenerate caches = 10
It’s mean that calling 10 apis in the second? So if i have 100 apis, it’s takeing 10 seconds??
Yes if you set the timeout to 30 min, you would want an interval of 30 minutes, but keep in mind that we use the registered cron intervals from WordPress (by default you can choose hourly, twice daily and daily) you can however add your own interval.
the max number is the number of api calls per interval. So if you set it to 10 and your interval to 30 minutes it will regenerate 10 caches every 30 minutes. So in your case you would want to set it to the number of api’s (if your server can handle that many consecutive calls).
Who can me generate the api after expired?
I want automatically generate the api after 30 minutes..
So i want to set timeout 30 min, and generate every api after expired without regenerate caches that generated apis in one time…
Another think, regenerate_expired_caches() funstion regenerate all apis> or only who expired?
Who can me generate the api after expired?
I do not understand the question, can you please elaborate?
Another think, regenerate_expired_caches() funstion regenerate all apis> or only who expired?
It will only regenerate expired/flushed caches.
How can i make the regenerate api automatically when he is expired?
Thanks for your support
You can’t immediately have it regenerate once it expires. There simply isn’t a hook for the expiration of a transient. So all you can do is have the regeneration script run often enough. So you could for instance have it run every 15 minutes, while you have your expiration interval at 30 minutes. That way they should be regenerated very soon, but immediately is simply impossible
Sorry my english.
Maybe not the most elegant way…. but it works for now…
add_action( 'save_post', 'save', 1000 );
function save()
{
global $post;
$post_types = get_post_type($post);
$index = sprintf('%s/wp-json/wp/v2/%s', get_site_url(), $post_types);
$item = sprintf('%s/wp-json/wp/v2/%s/%s', get_site_url(), $post_types, $post->ID);
$headers = ['Accept' => 'application/json'];
wp_remote_get($index, $headers);
wp_remote_get($item, $headers);
}