quarterdome
quarterdome

Reputation: 1581

What are the best practices for caching 3rd party API calls?

Our team currently operates 4-5 applications, and all of those applications use various 3rd party services (SimpleGeo, FB graph API, Yelp API, StrikeIron, etc). There is large overlap between applications, and frequently we call the same APIs for the same input parameters multiple times. Obviously that is not ideal: it is slow and it is expensive (some of the APIs are not free).

What are the best practices for caching these API calls across multiple applications? I see several options:

  1. Write a custom app that creates facade for all of those APIs, and change all of my apps to use it.
  2. Configure some sort of HTTP proxy in a very aggressive caching mode, and perform connections to APIs via that proxy.

Are there any other options I am missing?

Is there anything wrong with option 2? What HTTP proxy would you recommend for it (Squid, Varnish, Nginx, etc)?

Upvotes: 2

Views: 1885

Answers (1)

ivy
ivy

Reputation: 5559

You can use any of the three, but I would go with squid. Squid was created (and is heavily used) for this purpose (as a caching proxy). Varnish is designed as a Reverse Proxy (a cache in front of your own back-end), and nginx more like a load balancer and web processor (serving files and dynamic pages).

Upvotes: 2

Related Questions