Does growthbook a/b testing work with React server...
# ask-questions
b
Does growthbook a/b testing work with React server side rendering? I found client side rendering example using CSR but couldn't find anything about SSR. https://dev.to/jdorn/ab-testing-with-create-react-app-53fg Also docs don't mention anything about it. https://docs.growthbook.io/lib/react
f
Yes, it should work for SSR. The React SDK does not rely on any browser-specific features
b
ok great. and It says "Local targeting and evaluation, *no HTTP requests*" what does it mean? Shouldn't it fetch a/b tests data like percentage from growthbook?
f
The SDK itself just takes a JSON object as input with all of the feature and experiment configuration data. Fetching and caching that JSON file is up to you
👍 1
b
how does it serve variants based on percentage?
logic is based on Math.random or something else?
f
We hash the user id and experiment id to a number between 0 and 1. Each variation is assigned a range and the user is assigned whatever range they fall into
We use the FNV hashing algorithm.
b
I read that but one thing I don't understand how does it decide which user will fall into which range on their first visit?
f
The other thing you pass into the SDK besides the experiment configuration are user attributes. These include things like logged in userId, anonymous deviceId, etc.. You are responsible for generating and storing these IDs yourself, whether that's in cookies or elsewhere.
As long as you pass the same user id in, they will be assigned the same variation
b
I get how repeat visits works. but my question was for first visit where library decides to assign x% user to variation a and y% user to variation b. if it is server side i know server can split traffic based on x and y % and serve variants but for client side library how does it can determine this percentage distribution?
f
It works exactly the same way. You pass in a user id and experiment configuration and it does the hashing to assign a variant. Doesn't matter if it's client side or back end.
👍 1
b
okay and where growthbook server and db is hosted? I am interested in this so I can determine latency when I do client side fetch from various locations to growthbook for experiment data.
f
GrowthBook cloud is hosted in AWS us-east, but we have a global CDN in front of the feature endpoint. We also recommend people use a caching layer within their own infrastructure like Redis.
b
thanks for prompt response. If I update something in GrowthBook cloud. how long it takes for old data to be purged from the cdn cache?
f
Up to 1 minute
1