Optimizing API Interactions—Receiver
Learn how to improve API interactions as a receiver.
Let us look at how we would optimize our API interactions if we owned the routes that accept incoming traffic. Essentially, we want to be able to receive a request, process it swiftly, and respond efficiently, all in as little time as possible. Let’s take a look at how we could do that.
Use caching effectively
We discussed caching as a caller, but what about as a receiver? If we serve resources that don’t change frequently, we must consider caching them ourselves! There are two ways in which caching concepts can be applied.
Using in-memory or external cache
An in-memory cache should suffice for smaller data sizes, but consider using an external cache, like Redis, for larger datasets. We could cache the data we want to serve corresponding to a query in a data store easily accessible to us instead of having to compute the entire result set again. This is especially useful when we have heavy computation or database queries involved.