I am trying to build a single page web application that will call multiple web services (both SOAP and RESTful) and aggregate the data in the UI.

Initially I though I could do it all client-side, with ajax requests, but I realize that

  • If there are many requests, and they are fired per user, the data can take a long time to load.
  • If there are a lot of users, then I can easily reach my limit of API calls.

So now I'm thinking that I will have to have some kind of server-side process that runs every hour (or whatever), retrieves the items, and inserts/updates them in a database. Is this the right approach? Are there any other pitfalls I need to avoid?

1 Answer 1


Whether your web app is a single page design or a more traditional multi-page design your concern about API call limits applies equally.

If you haven't already become friends with memcache (or similar service on your platform).

You don't necessarily have to setup a cron to run once an hour.

Whenever a user requests information that requires a third-party service call:

  1. For first time calls, make API call to third party service
  2. After getting a successful response back from API call, cache the result
  3. Set cache expiration time to a value that makes sense for that type of data (some data can be cached for a week, while other data should only be cached for a few minutes)
  4. Every subsequent request for data, check if the cache exists and has not expired for that piece of data, if so return it, otherwise, go to step #1

A bonus of using a caching system similar to memcache is speed, since the data sits in memory it is orders of magnitude faster than a database query or making a third-party API call.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.