Recommended settings for CloudFront? Keep getting cache misses

Hello,

We’re using CloudFront in front of Netlify on https://app.monarch.io, and 90% of the time get cache misses. We’re using the default CF settings when it comes to caching / origin behavior and was wondering if there was a recommended set of CF settings we need to use to ensure cache hits.

We’ve also noticed that unless we tell Netlify to use cache-control: immutable, max-age=xxxx, the load times for our assets is extremely high.

We’re not sure what’s going on between CF and Netlify, but it seems that relationship is causing long load latencies since using Netlify alone has significantly faster loading.

@theogravity Welcome to the Netlify community.

Doesn’t Netlify use Cloudfront by default?

I talked to support regarding if they used CF under the hood. They responded that they use various CDNs underneath. For Netlify Functions, they do use AWS Lambdas under the hood.

They also sent this link out regarding proxying to Netlify:

1 Like

Hey there @theogravity

While we do not provide tech support on proxying to Netlify, this is the article I’d most strongly suggest you read about maximizing our CDN cache usage, which should help with performance (and explain the reason behind our default cache setting which we discourage you from changing as you mentioned):

[Support Guide] Making the most of Netlify’s CDN cache

I went through AWS support to diagnose the issue.

Cloudfront won’t cache because Netlify returns max-age=0, and our CF cache settings had a minimum of 1s for it to be cached.

We used the custom headers feature of Netlify to set a max-age=1800 (30 mins), and now CF is showing cache hits.

hey there, @theogravity :wave:

Thanks for sharing what steps you took! This is beneficial for future Forums users who may encounter something similar, so we really appreciate you circling back here.