Using ESI in the pagebuilder layouts template sometime breaks. You'll get message 'Previewed page is not based on a content item. Page Builder is working with limited set of features.' and the page is broken when for instance preview/editing (/admin/page/preview/257) the landing page.
I am not able to reproduce the actual problem on a vanilla ezplatform-ee (where I just add a render_esi() in layouts template. I have tested that both with varnish (locally) and with Fastly on Platform.sh. However, I have one other site on platform.sh with Fastly in front where the problem is 100% reproducible.
Fastly seems to behave slightly different on the site which have the problem. I don't know why that is, but I have now a understanding of what's going on.
Cause of problem
The page will contain such js:
The issue here is the esi :
Since the src starts with \\\", the syntax is invalid, varnish will discard the whole thing, fastly will too on one of my installations, but not on the other. And when fastly instead tries to load that esi, then everything breaks. The ESI tag will be replaced with a html fragment and that renders this JSON invalid....
So I think the fix is to make sure that ESIs are removed when generating this blocksConfig JSON.
In order to inspect the output of the pagelayout controller on a site with varnish:
1st, Login using a browser in order to get a session. Use browser debugger to get session cookies
Next, get user context hash:
Get the pagebuilder page: