I need to show something based on a user's session attribute, and with full page caching, my understanding is the best way to do that is by adding an httpcontext variable based on that session value. I'm using beforeDispatch, and seeing some odd behavior.
When I first start loading the page, the X-Magento-Vary starts off at one value which is incorrect, and so the page loads the incorrect content. Shortly after the page starts loading (and before it's finished), the X-Magento-Vary value changes to the correct one, but at that point it's too late.
Since customer group / logged in state are used, I'm assuming other data from the customer session is acceptable to use here. Is there any good way to diagnose what's going on there?