straight-state-82634
08/19/2025, 8:30 AMexport const gbInstance = reactive(
new GrowthBook({
apiHost: "<https://cdn.growthbook.io>",
clientKey: "sdk-xxx",
...
})
)
But this generates a lot of CDN requests (We are in starter plan and just make the experiment online for 2 days, it becomes 12M requests 😢).
To reduce requests, we’d like to add a backend cache layer.
Our idea is to set up a custom backend endpoint like:
export const gbInstance = reactive(
new GrowthBook({
apiHost: "<https://custom-backend-endpoint/growthbook>",
clientKey: "sdk-xxx",
})
)
And implement the backend API:
GET <https://custom-backend-endpoint/growthbook/api/features/{sdk-key}>
This backend service would use the Ruby SDK to fetch feature settings from GrowthBook Cloud CDN, cache them, and then serve cached responses to the frontend.
def index
render json: { status: 200, features: growthbook_features_json(params[:sdk_key]), dateUpdated: Time.current.iso8601 }
end
private
def growthbook_features_json(sdk_key)
Rails.cache.fetch("growthbook_features_#{sdk_key}", expires_in: 1.hour) do
features_repository = ::Growthbook::FeatureRepository.new(
endpoint: "<https://cdn.growthbook.io/api/features/#{sdk_key}>",
decryption_key: nil,
)
features_repository.fetch || {}
end
end
👉 Is this architecture supported / recommended?
👉 Would the JS SDK work properly if apiHost points to our custom backend instead of the GrowthBook CDN?
Thanks!fresh-football-47124
fresh-football-47124
fresh-football-47124
straight-state-82634
08/19/2025, 12:50 PMstraight-state-82634
08/20/2025, 1:28 AMfresh-football-47124
straight-state-82634
08/20/2025, 1:32 AM