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

brash-whale-8290

06/01/2022, 6:33 PM
HI all, Just starting to play around with the SDK’s. They are pretty easy to get up and running, but none of the examples are for server side features. Are they any example implementations against things like an node or expressJS server that shows best practices for refreshing the features list?
f

fresh-football-47124

06/01/2022, 6:50 PM
Hi Joshua
Let me get you some example code
b

brash-whale-8290

06/01/2022, 6:59 PM
I wouldn’t want to hit your API on every api hit to my page. But I also want to refresh my features every X minutes. I’m googling around and new to node & express, and don’t know the best practices for having a background thread call
setFeatures
f

fresh-football-47124

06/01/2022, 7:31 PM
the caching can be done any way you like, here is one that looks like it will work: https://dev.to/franciscomendes10866/simple-in-memory-cache-in-node-js-gl4
b

brash-whale-8290

06/01/2022, 10:34 PM
I ended up going with a node-cron approach. snippet shared
Untitled.txt
maybe it is useful for someone else.
f

fresh-football-47124

06/01/2022, 10:35 PM
nice, do you mind if I use that... great 🙂
b

brash-whale-8290

06/01/2022, 10:35 PM
You fire that function at boot, and it goes and does its thing.
f

fresh-football-47124

06/01/2022, 10:36 PM
on line 9 it seems to do the fetch regardless, no?
b

brash-whale-8290

06/01/2022, 10:46 PM
I don’t want the app to start without fetching the features first. That cron won’t fire for a minute.
12 Views