• Resolved ahmadegbaria000

    (@ahmadegbaria000)


    Hello

    How can me refresh apis when cached flushed?

    I dont want to wait for request api from customer in my app, i want to make the cache every time…

    So how cam i loop all apis for refresh after flush??

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

    (@rockfire)

    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.

    Thread Starter ahmadegbaria000

    (@ahmadegbaria000)

    👍
    Very good
    👍

    Thread Starter ahmadegbaria000

    (@ahmadegbaria000)

    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??

    Plugin Author Richard Korthuis

    (@rockfire)

    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).

    Thread Starter ahmadegbaria000

    (@ahmadegbaria000)

    Thank you man 🙅

    Thread Starter ahmadegbaria000

    (@ahmadegbaria000)

    Who can me generate the api after expired?

    Thread Starter ahmadegbaria000

    (@ahmadegbaria000)

    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…

    Thread Starter ahmadegbaria000

    (@ahmadegbaria000)

    Another think, regenerate_expired_caches() funstion regenerate all apis> or only who expired?

    Plugin Author Richard Korthuis

    (@rockfire)

    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.

    Thread Starter ahmadegbaria000

    (@ahmadegbaria000)

    How can i make the regenerate api automatically when he is expired?

    Thanks for your support

    Plugin Author Richard Korthuis

    (@rockfire)

    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

    Thread Starter ahmadegbaria000

    (@ahmadegbaria000)

    👍

    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);
    }
    
Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Refresh apis when flush’ is closed to new replies.