02-06-2012 10:26 AM
I have built a little script that takes the playlists added to it and it returns a bulled list of videos for each playlist. I have worked hard to ensure that adding this to the dom is most efficient. The problem is the first time I hit the api with a query it is taking 1.5 seconds or more. Subsequent requests are much faster (I assume caching). Is there anything that can be done to speed up that intial query?
What is the cache time 5 mins? Can that be increased?
At times I am grabbing 15 playlists wiht about 5 videos each. Here is what the request looks like:
Solved! Go to Solution.
02-15-2012 02:23 PM
You're correct that we are caching the response, and that's why it's faster the second time around. The cache time is not a constant; it's based on request frequency---so if something is requested often we will keep it in the cache longer (while also trying to keep the content up-to-date).
One option you could try: instead of loading the playlists and their videos in one request, you could just grab the video IDs for each playlist and then make separate requests for each video.
Here I've removed the video_fields parameter and added playlist_fields=id,name,videoIds. After this request you would iterate through the video ids and make several "find_video_by_id" (or "find_videos_by_ids") requests.
Obviously the trade-off there is that you end up making many smaller requests, but as they are fetching less data they should return faster.
hope that helps,