Forums Forums Search & Filter Pro Background cache update & force cache refresh

Viewing 6 posts - 1 through 6 (of 6 total)
  • Anonymous
    #58970

    Hi,

    I have 2 questions about caching. My search is based on post imported by a third party pluggin, when they are imported, it seems that the cache refresh is not launched. I need to go to search form, click on the cache rebuild to make it work.

    1) When I click on this button I have the message “Notice: Running background processes is either disabled or has failed in this environment. Therefore you must leave this page open to complete caching.”, I did not found any information how to fix the setup to allow background process.

    2) Is there any command url to force cache update without going through the admin that I could cron/fire ? If yes, does it need to have the background process fixed first ?

    Regards:

    Ross Moderator
    #58976

    Hey Sylvain

    You can rebuild teh cache for a particular post using this action:

    https://www.designsandcode.com/documentation/search-filter-pro/action-filter-reference/#Update_Cache_for_a_Particular_Post

    So every time a post is imported, run this 🙂

    You don’t need to worry about the cache, the warning is only when doing a full rebuild of the cache.

    Even then its only a warning, it likely means wp_remote_get is not working in your environment, or you are working in a staging environment that is password protected (in addition to the WP login).

    Thanks

    Anonymous
    #59015

    Hi Ross,

    Thank you for this reply, I’ve seen the cache update for a particular post but as they are imported by a 3rd party plugin I was looking for a “global” cache refresh command that would prevent me to hack the plugin to call the individual update at each save.
    I’ll try this if there is not another option.

    Ross Moderator
    #59105

    Hey Sylvain

    I’m afraid there is not a reset function to rebuild the whole thing – but this can be a very expensive (resource intensive) process – especially if you are adding a lot of posts… Doing it 1 by one would be the way to go for sure…

    How many posts do you think you’ll be handling?

    Almost any “big” importer plugin I’ve seen will have a wordpress action/filter after each post has been added, so you would need to combine their action/filter with ours above and you could have this fully automated 🙂

    Thanks

    Anonymous
    #59734

    Hi,

    Sorry for late answer, I was off 2 days.

    So following your advice, I’ve added an function to save_post hook but it does not seem to solve my issue. After the import I can’t have any result on my search.

    Do I miss something ?

    function update_sf_cache( $post_id ) {

    $post_type = get_post_type($post_id);

    // If this isn’t a ‘used_vehicle’ post, exit.
    if ( “used_vehicle” != $post_type ) return;

    // Update the search & filter cache for this post.
    do_action(‘search_filter_update_post_cache’, $post_id);
    }
    add_action(‘save_post’, ‘update_sf_cache’);

    Ross Moderator
    #60662

    Hi Sylvain

    The save_post hook I do not believe is the correct one (S&F already uses this).

    The importer plugin should have its own custom hook for after a post has been imported – I’ve seen this with some importers before.

    Best

Viewing 6 posts - 1 through 6 (of 6 total)