I'm using the facebook and instagram APIs in a project. I basically do the query of posts respectively of each social network and I insert in the database of wordpress, I saved the ID of each post and I do a check before entering not to insert duplicate posts.
But whenever I load the site, it takes time to load because it searches for posts on facebook and instagram, which is damaging the performance of the site.
What I want to do is that this search for new posts in instagram and facebook be done only once a day. If a user enters the site and performs the search, the next users will no longer perform this search. And then the next day the first user performs the search and the others do not and so on.