For a long time I've been having an issue with the top navigation bar in Magento 2.3 not showing the first time a page is requested after varnish cache is cleared. On subsequent requests of the same page (e.g hitting Refresh) the nav bar shows normally. This happens on any page: Home page, Category Page, Product page, Search etc.
The issue is obviously related to varnish because the <esi:include>
for the nav bar is left intact but other <esi:include>
are processed normally.
I've tried clearing caches, setup:di:compile, redeploying static content but nothing worked so far. I am at a loss as to how to troubleshoot the issue.
Using Magento 2.3.4 with Varnish 4.0.2. I cannot really modify varnish configuration/VCLs as this is managed by my host (Cloudways)
Related logs:
Varnish log
Apache access log
magento2_recv.vcl
magento2_backend.vcl
(Please note logs have been truncated to only include related requests, but still they are to large to embed in the question)