How to cache Web API response?

Generally speaking, does a wrapper class make an API call slower?

  • I am sure the first answer to this question is "it depends", but what I am trying to find out is, if a web application is heavily dependent on API calls to sites like LinkedIn or Facebook, does it make a difference in response time/ server load if one uses a wrapper class to call the API as opposed to directily interacting with the API? In other words, is the use of wrapper class worth it?

  • Answer:

    You're right that the answer is "it depends" on the wrapper itself. I'd say though that assuming the wrapper isn't poorly written the extra time passing through the wrapper code should be negligible v's the time taken to make the actual call out. An API call out can be 50-100ms for fast APIs, more in some cases. It's unlikely a wrapper will add anything close to that. If you skip the wrapper then you'll most likely still need code to call the API (which will have it's own execution time). The advantage of a wrapper is that you can better compartmentalize code and abstract the actual API calls to make it more maintainable. Further if the API wrapper is provided by the API provider then it may be easier to do updates in the in future than with your own custom code. In some cases the wrapper might even call the API in a smart way to cut down the number of calls. Mainly comes down to how good the wrapper code is. If you look at it and start itching to optimise it then you probably have your answer...!

Steven Willmott at Quora Visit the source

Was this solution helpful to you?

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.