Reply
Visitor
MStahl
Posts: 9
Registered: ‎09-21-2011
0 Kudos
Accepted Solution

Slowness using json with findplaylists by ids

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:

https://api.brightcove.com/services/library?command=find_playlists_by_ids&playlist_ids=1340639357001...

Brightcove Team
BC-ChrisTierney
Posts: 162
Registered: ‎12-12-2008
0 Kudos

Re: Slowness using json with findplaylists by ids

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.

 

https://api.brightcove.com/services/library?command=find_playlists_by_ids&playlist_ids=1340639357001...

 

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,

.chris