Hey! I was wondering if anyone tried implementing ...
# ask-questions
b
Hey! I was wondering if anyone tried implementing Growthbook while using Varnish in front of the application server, whilst keeping the logic server side, I’m having trouble to conceptualise it.
f
Hi Robinero - That may be possible, but knowing when to update the cache would have to be figured out
alternatively, you can use our GrowthBook Proxy to achieve a similar effect
b
Hey Graham, the proxy acts as a Growthbook instance with a cached output, right? In my case the Varnish server would be in front of the application that’s going to be feature toggled, sort of like Fastly.
f
@happy-autumn-40938 any insights on how Robinero could do this? ^
h
I don't think the GrowthBook Proxy directly addresses this. Generally speaking though, you'd probably want to either set a short enough TTL that cache doesn't stay stale for too long, or rig up a cache
ban
or
purge
trigger on your Varnish server whenever features change. You could technically use a GrowthBook webhook to hit some sort of listener on your infrastructure (varnish server directly, lambda, etc) that would handle the cache purge.
One other option that is far more experimental would be installing a GB SDK in front of your cache server (like as a CDN / edge worker). We don't officially support this at the moment, but you may have some success here.
b
Hey, thanks for getting back to me! It’s not so much the ‘when will caches need to be purged’, but rather the ‘how does Varnish know which page to serve’, all the while keeping the flexibility GB provides. I’m leaning in the run a separate GB SDK direction, throw a unique ID at it, and let it return some flags to query on inside Varnish.
Gonna require a bit of tinkering, but might just be the way to go.