https://www.growthbook.io/ logo
h

hallowed-toothbrush-30835

06/23/2023, 6:33 PM
Hello Everyone, I trying to make a very basic example with feature flags on nextjs 13 for record a video demo in youtube, but I still receiving the same value... Anyone know if it's is compatible or what's wrongs with me? 😛
f

fresh-football-47124

06/23/2023, 6:34 PM
hi Felipe
h

hallowed-toothbrush-30835

06/23/2023, 6:34 PM
hey
f

fresh-football-47124

06/23/2023, 6:36 PM
probably a cache delay - let me enable real time updates for your SDK
h

hallowed-toothbrush-30835

06/23/2023, 6:37 PM
ohh ok
I added
_await_ growthbook.loadFeatures({ autoRefresh: true, skipCache: true });
skipCache on the loadFeatures...
It resolves?
f

fresh-football-47124

06/23/2023, 6:40 PM
try it now
1
h

hallowed-toothbrush-30835

06/23/2023, 6:43 PM
I don't know why, but still ignoring the force rule 😕
f

fresh-football-47124

06/23/2023, 6:43 PM
Can you add a log of the getFeatures()?
h

hallowed-toothbrush-30835

06/23/2023, 6:44 PM
yep
just console.log('running') resolve?
f

fresh-football-47124

06/23/2023, 6:45 PM
well, I don’t see you setting the apiHost anywhere
h

hallowed-toothbrush-30835

06/23/2023, 6:45 PM
Copy code
const growthbook = new GrowthBook({
  apiHost: "<https://cdn.growthbook.io>",
  clientKey: "sdk-HZXDl2WDRqjPt9CJ",
  enableDevMode: true,
  trackingCallback: (experiment, result) => {
    // TODO: Use your real analytics tracking system
    console.log("Viewed Experiment", {
      experimentId: experiment.key,
      variationId: result.key,
    });
  },
});
f

fresh-football-47124

06/23/2023, 6:45 PM
ah
h

hallowed-toothbrush-30835

06/23/2023, 6:45 PM
image.png
feature is loading...
f

fresh-football-47124

06/23/2023, 6:48 PM
add
console.log("all features", growthbook.getFeatures());
around line 27
h

hallowed-toothbrush-30835

06/23/2023, 6:49 PM
bingo
f

fresh-football-47124

06/23/2023, 6:50 PM
huh
my-feature-1 is an old feature you had?
h

hallowed-toothbrush-30835

06/23/2023, 6:52 PM
yep
these are the new values
f

fresh-football-47124

06/23/2023, 6:54 PM
@happy-autumn-40938 do you know why the cache would not be clearing?
h

happy-autumn-40938

06/23/2023, 7:07 PM
I don't think I would use
skipCache: true
unless there's a good reason to do so. In this case, it might be doing more harm than good. The CDN-cached payload (which incidentally uses a separate cache than what is controlled by
skipCache
in the SDK) is sometimes slow to respond to updates. We're actively working on resolving this. Meanwhile, streaming updates should allow your SDK to respond to GB changes more quickly. I'd want to know whether you're able to receive streaming updates. You can check your Chrome network tab and filter for our
/sub
endpoint. As you toggle/modify a feature flag in the app, you should see a corresponding event appear on this endpoint. I'd start there and see whether that's actually updating for you.
h

hallowed-toothbrush-30835

06/23/2023, 7:18 PM
Hello Bryce,
skipCache
disabled. And I can't receive streaming updates (I'm using the free account to make a youtube video for my channel using next + gb)
h

happy-autumn-40938

06/23/2023, 7:22 PM
Ah, that could be it. We do have a free trial of Pro (self-serve) that should unlock streaming for you. No payment info required, it just turns off after the trial period. Please let us know if you'd like help getting everything set up.
h

hallowed-toothbrush-30835

06/23/2023, 7:23 PM
Ok! I see... I'll try so. Thanks so much Bryce and Graham ❤️
🥳 1
I don't know it is relevant, but when I create a new SDK it's "reloads" the cache and the new values are in.
Look for before and after in my console.
h

happy-autumn-40938

06/23/2023, 7:25 PM
yep that makes sense. The CDN caches by api key.
h

hallowed-toothbrush-30835

06/23/2023, 7:26 PM
But in this case, I up the docker image on my PC (it's running localhost)
I upped a docker container to skip cache issues, and this keep occurring.
I'll try to use next using react on the browser (as client) and see if keep the same pattern.
h

happy-autumn-40938

06/23/2023, 7:28 PM
I see. On self-hosted, the SDK endpoint is not cached by a CDN unless you set it up manually. At this point, you'd mostly be dealing with SDK and network cache
Locally, to reduce the SDK cache time, you can try setting:
Copy code
configureCache({
  staleTTL: 100 // 0.1 seconds
});
h

hallowed-toothbrush-30835

06/23/2023, 7:32 PM
Where I put this code?
h

happy-autumn-40938

06/23/2023, 7:33 PM
right after initializing your SDK
(line 15 for you)
1
2 Views