• Resolved brnteka

    (@brnteka)


    Thank you for the plugin, but i have a question, is it possible to programmatically flush all cache of a specific post type and then regenerate it? I have a cron job that runs once a day and updates all posts of custom type, and after its done all the cache should be flushed and regenerated with the new posts data. Thanks.

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

    (@rockfire)

    Hi @brnteka

    Thank you for using our plugin!

    You are actually asking two different things (flushing and regenerating), so I am going to answer them seperately.

    Yes it is possible to flush all caches of a specific post type programmatically. For instance if you would like to flush all caches of a post type products you can do so like this:
    \WP_Rest_Cache_Plugin\Includes\Caching\Caching::get_instance()->delete_object_type_caches( 'products' );
    But I must say: why would that be needed? If you update the post using WordPress core function the caches should be flushed automatically. Isn’t this the case in your situation? Or are you updating the posts with a direct database query?

    About regenerating: we don’t have the option to regenerate specific post type caches, but we do have the option to automatically regenerate flushed (or expired) caches. See our FAQ on how to set this up.

    Thread Starter brnteka

    (@brnteka)

    But I must say: why would that be needed? If you update the post using WordPress core function the caches should be flushed automatically. Isn’t this the case in your situation? Or are you updating the posts with a direct database query?

    I’m using Carbon Fields so this might be the case, but i call wp_update_post function as well, and fields updated with CF API doesn’t seems to be flushed.

    About regenerating: we don’t have the option to regenerate specific post type caches, but we do have the option to automatically regenerate flushed (or expired) caches. See our FAQ on how to set this up.

    If selected “once a day” what time it would be exactly? Would be great if i could set the time to be somewhere near after the end of a cron job.

    Thank you for the quick response

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Programmatically flush and regenerate cache’ is closed to new replies.