3
3
Table of Contents

In today's cloud-native landscape, API gateways play a critical role in serverless and microservices architectures. This is a powerful tool for building scalable APIs, but it's also easy to overlook the cost-effectiveness, especially if the APIs are frequently called or redundant. For FinOps practitioners who are sure to focus on reducing costs without compromising, the use of API Gateways integrated with a cache is a game-changer.

What Is API Gateway Caching?

Amazon API Gateway provides integrated response caching, interfering with edge layer endpoints, eliminating the need to access back-end services (such as Lambda, EC2, RDS) for each request.
Here’s how it works:

  • When caching is enabled on a stage or method, API Gateway stores responses in an in-memory cache.
  • Subsequent requests with the same parameters hit the cache instead of the backend.
  • You control cache TTL (Time to Live) and cache keys for precision.

How Should Cache be Handled? 

1. Reduce Backend Invocation Costs

Back-end views (such as Lambda or RDS calls) often incur the majority of API-related costs. These calls are avoided in intermediate storage if the same query from the cache is being operated on.

2. Control Data Transfer Charges

Output data transmission (especially for large payloads) is reduced, leading to savings in data transmission costs (DTO).

3. Enhance User Experience

Faster response times and lower latency mean you don’t need to scale up infra  (saving both cost and operational effort).

Use Case

Suppose you want to run the Product Catalog API for your e-commerce platform. To retrieve the product listings.

Without caching:

  • Every user requests to call the backend service.
  • During high usage, our backend suffers from the load, and it impacts the performance.
  • Each query adds latency due to DB access and data processing.

With Caching Enabled: 

With Caching Enabled:

Multiplying this by multiple APIs can save thousands of dollars each year.

How to Enable Caching (Step-by-Step)

Sign in to the API Gateway console.

  • Choose Stages.
  • In the Stages list for the API, choose the stage.
  • In the Stage details section, choose Edit.
  • Under Additional settings, for Cache settings, turn on Provision API cache.
  • This provides a cache cluster for your stage.
  • To activate caching for your stage, turn on Default method-level caching.
    This turns on method-level caching for all GET methods on your stage. Any additional GET methods that you deploy to this stage will have a method-level cache.
    Note: If you have an existing setting for a method-level cache, changing the default method-level caching setting doesn't affect that existing setting.

Note: If you have an existing setting for a method-level cache, changing the default method-level caching setting doesn't affect that existing setting.

  • Choose Save changes.

For more information, please refer to the Amazon official Document.

Pro Tip:

Use stage variables to toggle caching across environments without redeploying code.

When to Use API Gateway Caching

Ideal For:

  • Read-heavy, infrequently changing endpoints (e.g., product catalog, FAQs, blog posts).
  • Microservices with repetitive payloads.
  • APIs fronting expensive operations (DB lookups, ML inference).

Avoid Caching When:

Data changes frequently (e.g., real-time stock prices).

You require request-by-request freshness (e.g., personalized responses).

Best Practices

Best Practices

Conclusion

API Gateway Caching is one of the easiest ways to reduce costs and improve performance. Doing more in less amounts. If you're managing serverless APIs or want to advise your team on cost strategies, put caching in your roadmap today.

12
Let's discuss your cloud challenges and see how CloudKeeper can solve them all!
Meet the Author
  • Varshit Agarwal
    Senior Software Engineer

    Varshit is a Senior Software Engineer with over five years of experience in DevOps and Platform Engineering.

Leave a Comment

Speak with our advisors to learn how you can take control of your Cloud Cost