Hi @Tom360, I haven’t specifically used Lambda@Edge, but I can give my thoughts.
Say you have a header designed as a section within Builder. The header has a text block showing the user’s name populated with a dynamic data binding. Maybe that’s the short answer you’re looking for and you can stop reading now .
The data binding is just a bit of JS code, something like state.fullName
. At least when using the React SDK, the one I’m most familiar with, the binding will execute twice (not including re-renders on the browser): once on your back end during SSR and once in the browser during hydration. The SDK is what executes the binding code, spits out a result, and associates it with your text block’s value.
So in this case, which is a pretty typical use case, the binding itself is what’s part of your header’s content and that’s what gets fetched by your server from Builder, not the end result. CloudFront would end up caching the binding JS along with the rest of your header section’s content (info about layout, which blocks are in the header, styling, etc.) But the code executes per render since it’s executed by the SDK.
A separate but related question is “how does state.fullName
get populated?” Well, the state
variable in Builder is a complicated beast with many potential inputs, but in this case, typically you would pass your state into the SDK during render. If you’re using React, it would be <BuilderComponent data={...} />
, where data
is the prop that populates state
. Then at render time, the SDK executes the data binding with the state
you’ve just populated within the execution context (during SSR, the execution context is a Node VM, and during CSR it’s a closure with state
in scope).
The point is, state
isn’t getting cached, either–at least, not if you populate it using the data
prop. There are ways to pre-populate state as part of the section content, in which case that would get cached, but you’d have to go out of your way to do it. At any rate, anything that you pass into the data
prop has precedence when it comes to populating state
.
Hope that helps.