Forums › Forums › Search & Filter Pro › Background cache update & force cache refresh
- This topic has 5 replies, 2 voices, and was last updated 8 years, 7 months ago by
Ross.
-
Anonymous(Private) September 20, 2016 at 11:25 am #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(Private) September 20, 2016 at 12:02 pm #58976Hey Sylvain
You can rebuild teh cache for a particular post using this action:
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(Private) September 20, 2016 at 2:18 pm #59015Hi 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(Private) September 20, 2016 at 9:10 pm #59105Hey 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(Private) September 23, 2016 at 2:06 pm #59734Hi,
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(Private) September 27, 2016 at 7:23 pm #60662Hi 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
-
AuthorPosts