https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
n

narrow-printer-24953

09/28/2022, 6:01 PM
Hey, team! I just started using GrowthBook in our React application. Going through the documentation, I saw a comment that got me intrigued:
Copy code
// Load feature definitions from API
  // In production, we recommend putting a CDN in front of the API endpoint
  fetch('api-endpoint')
    .then((res) => res.json())
    .then((json) => {
      growthbook.setFeatures(json.features);
    });
What I’d like to know is why are putting a CDN in front of the API endpoint recommended in this instance? Is the API endpoint private?
f

fresh-football-47124

09/28/2022, 6:02 PM
its more about reducing 3rd party dependancies
if you’re using our cloud, we have a CDN already
if you’re self hosting, that’s up to you
you can also cache it or store it locally for speed
n

narrow-printer-24953

09/28/2022, 6:03 PM
Oooh, okay. That makes sense. We are self hosting.
I’ll definitely implement caching for this feature.
Tyvm 😌
f

fresh-football-47124

09/28/2022, 6:04 PM
sure thing
f

fierce-church-81643

10/18/2022, 9:38 AM
@fresh-football-47124 what do you have to cache locally in my app? The response from the API endpoint (directly or behind CDN)?
… or is it needed to request the API for each user/page request?
f

fresh-football-47124

10/18/2022, 9:45 AM
we encourage caching of the feature json
is that what you mean?
f

fierce-church-81643

10/18/2022, 11:27 AM
Yes indeed. So the assignment also works locally (because you get all experiments + config in that JSON)? Does this approach also works for distributed frontend apps?
11 Views