I need some help with Youtube API data optimization. In my app, I'm getting YT videos data by stored video id in my database. But there's a problem with longer site loading than usual.
well can you be more prespective , is Youtube your model name or the used API ?
if any of them why are you looping then calling the data in each load this is the reason of this slowly ,
as better approach you should get all videos from your model / API then loop at them one time ..
@abdelhammied, I have a Video model where I have stored youtube_video_id of each video. I looping them through foreach and getting video data through the Youtube API (using alaouy/youtube package).
Calling to the YouTube api like that is going to slow things down. You also risk rate limits and getting blocked. You should cache everything from the API and refresh it every so often. Even if you can live with the delay in rendering that page, if you are putting this on a live site, then you will face huge problems down the road.