Improving Rest API Performance Using Cloudfront


Recently we started working with a healthcare company that was facing slow API response time causing a bad user experience. The customer is a US-based Healthcare company solving the lack of healthcare interoperability with its patient-centered mobile platform, from where patients can engage, communicate and participate in their healthcare across various providers that might be using different PM/EHR/EMR products.

The product includes a SaaS platform for healthcare providers to share and communicate patient health information along with its cutting-edge point-of-service patient check-in app for waiting rooms.

Due to the complex nature of the product, one of the requirements of the product team was to solve this issue without changing a lot of existing code. The client had already evaluated a couple of paid tools that were working great but very costly, so another challenge was to find an open-source tool that can serve the purpose. Hence, we had a two-pronged challenge- Improve performance and reduce cost.

We started doing some research and found tools like Solr which seemed like a good fit for us initially, but while we were almost close to setting it up, we thought to get some detailed insights from API response times which opened up new revelations for us making Solr insignificant. Some of the stats from different APIs were like this –

Before Cloudfront:

PCP2192 ms662 ms30%
Allergy3758 ms475 ms12%

So after looking at low level timings, it was found that database call was not that a bigger culprit, there were some calculations happening on backend which were causing the major delays along with SSL handshake and a few other things. So we started rethinking about a new approach to solve this problem.

Few months back I had seen Slack case study on AWS and how they improved their API performance using Cloudfront. This triggered me to go back and check AWS documentation for the same. I started playing around with Cloudfront for custom origins. Till now, we had used CloudFront alongside S3 for static website hosting which had worked well.

After configuring cloudfront for one API we were able to achieve almost 233% improvements in API response time without changing single line of code on backend. Below figure depicts the results after using Cloudfront.

PCP2192 ms14 ms197%
Allergy3758 ms16 ms233%

We Helped Our Client To Convert The Old Application Into A New Stack

So far all good, but how to configure Cloudfront to achieve such results? Below are the steps which can help anyone to configure Cloudfront with existing APIs.


Pravin Uttarwar, CTO Mindbowser Group

At Mindbowser, we bring the best of technology & knowledge for founders. In case you would like to discuss your options further, feel free to book a 30 minutes consultation call.

Get Free Consultation!

Create Cloudfront Distribution:

  1. In the CloudFront console, choose to Create Distribution.
  2. On the first page of the Create Distribution Wizard, in the Web section, choose to Get Started.
  3. For Origin Domain Name, enter your API URL, which is nothing but your current API URL(or base url e.g
  4. In Origin Path, keep as it is.
  5. For Origin Protocol Policy, choose HTTPS Only.
    Note: API Gateway does not support unencrypted (HTTP) endpoints. For more information, see Amazon API Gateway FAQs.
  6. To forward custom headers to your origin, enter one or more custom headers for Origin Custom Headers.
    Note: There are several custom headers that CloudFront can’t forward to your origin.
  7. Choose to Create Distribution.
  8. Wait for your distribution to deploy. This might take about 30 minutes. When its Status appears as Deployed in the console, the distribution is ready.

Configure Caching Using Behaviours:

Assuming Cloudfront is deployed, it’s time to configure behaviors for caching. I am using the above example to configure two APIs /search/pcp and /search/allergy to cache the content based on our needs. Here are the steps for same –

  1. Click on CF distribution
  2. Go to Behaviour Tab and click on Create Behaviour
  3. Enter path pattern – in my case of pcp API it was /search/pcp
  4. I will skip other settings which are self-explanatory, lets move to the main settings, select customize from Object Caching section, enter minimum TTL as 0, maximum and default value 31536000(this is max)
  5. Under Query string forwarding and caching select the option Forward all, cache based on whitelist, in text box enter all your query parameters which you want to be cached(meaning when these changes backend API response changes), in my case, it was Keyword, Limit, Page, PracticeId and Zipcode, enter one in each line
  6. Save the behavior

Once the distribution is ready, you can copy the Cloudfront URL and hit the API. Note down the response time. Now hit the same API again and compare the response time. You will see a big difference in the response time which means caching is working. Follow the above steps for adding multiple behaviors.


  • Handling Selecting Caching

While implementing one of the challenges was that we needed to cache the response only when certain request parameter value is available. In our case, our backend was sometimes hitting our own database or hitting third party depending on request parameter value. Whenever we are hitting third-party API we don’t want to cache the result. We have handled this using max-age=1 parameter in API response, so whenever Cloudfront finds max-age=1 it caches for 1 second and overrides default settings. Now backend has control on what to cache and when.

  • Automating Cache Updates

One of the requirements was to update the cache whenever the backend database is updated, so we wrote the AWS Lambda function to invalidate specific cache entries using Cloudfront invalidate API. We exposed this lambda function using AWS API gateway so that our backend can call the API and invalidate the specific cache entries based on which DB values are updated. I will cover this in our upcoming blogs.



The new architecture turned the response time down to less than half of the original resulting in faster responses which in turn made the end-user delighted. All this was done without having to change any aspects of the core application or any downtime for the application.

In the end, the customer was happy to see savings for a time as well as cost.

Pravin Uttarwar

CTO, Mindbowser

Pravin has 16+ years of experience in the tech industry. A high energy individual who loves to use out of the box thinking to solve problems. He not only brings technical expertise to the table but also wears an entrepreneurial hat – benefiting any project with cost savings and adding more value to business strategy. Pravin is also chapter director of StartupGrind Pune, hosting events and startup conferences.
Reach out to Pravin at

Get in touch for a detailed discussion.

Hear From Our 100+ Customers

Mindbowser helped us build an awesome iOS app to bring balance to people’s lives.


We had very close go live timeline and MindBowser team got us live a month before.

Shaz Khan
CEO, BuyNow WorldWide

They were a very responsive team! Extremely easy to communicate and work with!

Kristen M.
Founder & CEO, TotTech

We’ve had very little-to-no hiccups at all—it’s been a really pleasurable experience.

Chacko Thomas
Co-Founder, TEAM8s

Mindbowser is one of the reasons that our app is successful. These guys have been a great team.

Dave Dubier
Founder & CEO, MangoMirror

Mindbowser was very helpful with explaining the development process and started quickly on the project.

Hieu Le
Executive Director of Product Development, Innovation Lab

The greatest benefit we got from Mindbowser is the expertise. Their team has developed apps in all different industries with all types of social proofs.

Alex Gobel
Co-Founder, Vesica

Mindbowser is professional, efficient and thorough. 

MacKenzie R
Consultant at XPRIZE

Very committed, they create beautiful apps and are very benevolent. They have brilliant Ideas.

Laurie Mastrogiani
Founder, S.T.A.R.S of Wellness

MindBowser was great; they listened to us a lot and helped us hone in on the actual idea of the app.” “They had put together fantastic wireframes for us.

Bennet Gillogly
Co-Founder, Flat Earth

They're very tech-savvy, yet humble.

Uma Nidmarty
CEO, GS Advisorate, Inc.

Ayush was responsive and paired me with the best team member possible, to complete my complex vision and project. Could not be happier.

Katie Taylor
Founder, Child Life On Call

As a founder of a budding start-up, it has been a great experience working with Mindbower Inc under Ayush's leadership for our online digital platform design and development activity.

Radhika Kotwal
Founder of Courtyardly

The team from Mindbowser stayed on task, asked the right questions, and completed the required tasks in a timely fashion! Strong work team!

Michael Wright
Chief Executive Officer, SDOH2Health LLC

They are focused, patient and; they are innovative. Please give them a shot if you are looking for someone to partner with, you can go along with Mindbowser.

David Cain
CEO, thirty2give

We are a small non-profit on a budget and they were able to deliver their work at our prescribed budgets. Their team always met their objectives and I'm very happy with the end result. Thank you, Mindbowser team!!

Bart Mendel
Founder, Mindworks