Hi there,
We are currently evaluating how to best integrate Growthbook into our Next.js applications to improve our feature flagging ability and, more importantly, enable experimentation. A challenge we currently face with integrating Growthbook is that we use caching heavily. We rely on it so that traffic spikes can be handled at the CDN without introducing extensive load on the web servers, since some of the pages are resource-intensive to generate.
During server-side generation of pages, we therefore do not have access to a user identifier (or other information that would be unique to a single visitor). We would like to evaluate the experiments in an edge function and forward the result to the actual application. Unfortunately, we didn't find a way to initialize the SDK without including some sort of unique value or major restrictions in the usage of the SDK:
•
Using the Next.js SDK as documented: Requires a user ID for experiment evaluation (it makes sense that this is required to ensure a deterministic calculation of the experiment result).
•
Using proxy-eval to enhance the payload with the experiment results: The experiment results embedded in the payload contain the user ID.
•
Evaluating the experiments in an edge function and forcing the variations in the application via forced variations: This prevents tracking callbacks from being fired (this was proposed here, in a very similar usecase:
Slack Link).
We see two more options for integrating Growthbook (which we would like to avoid if possible):
• Using the Growthbook SDK only at the edge to evaluate features/experiments, pass a custom configuration to the application, and implement a lightweight feature flagging library in the application for feature switches and tracking.
• Extending Growthbook by adding a way to initialize the SDK with experiment results (excluding the attributes used for evaluation).
Questions:
• Are there ways of making this use case work that we have missed?
• Are there resources on how to set Growthbook up with server side caching?
• Regarding extending Growthbook: Is a functionality like this on the roadmap, and/or is this a use case that Growthbook should support in your opinion?
• If there is a way of implementing this that aligns with the roadmap, contributing such functionality would be an option.
Thanks!