I am using top_10_videos_api_call to get matching videos. I am updating start_date and end_date through date picker and I get updated data as expected. But is there way to cache data for same time period. e.g. If I select last month
-> last week
-> last month
, for second last month
call it shouldn't take 5-10 sec to get data which happens for first call.
Or is there better option to tackle this?

- 2,677
- 9
- 42
- 79
-
Have you tried the solution in this [SO thread](http://stackoverflow.com/questions/12109202/how-to-cache-rest-responses-spring-for-android)? Seems the post was looking for a way to cache rest calls also. – ReyAnthonyRenacia Apr 15 '17 at 13:10
-
1What programming language are you using? – paolo Apr 15 '17 at 16:11
1 Answers
This is definitely doable and also a very good idea to do! But how you should do it depends entirely on the system and components you are using.
For PHP you might want to take a look at this article on an easy caching system. On the server side it makes sense to cache data persistently (across multiple site loads), e.g. on the filesystem. The more complicated methods might require you to install certain PHP plugins, like memcached.
In client-side environments, like JavaScript, in-memory caching might suffice. A very easy method to cache REST data is to create an associative array where the keys are the request URL's and the values are the response of the server. So, before you issue another request with a certain URL, check whether that URL exists in your array and if so, use the respective value.

- 2,528
- 3
- 17
- 25
-
i'm using python djnago and jquery, add you can see it's query call `youtube_analytics.reports().query().execute()` are there any readily available libraries out there – user2661518 Apr 17 '17 at 21:13