This article provides configuration solutions to the Varnish Edge Side Includes (ESI) issues, where certain pages' content, usually the top navigation panel, is not displayed on the store front, if Varnish is used for caching.
Affected products and versions
- Magento 2.X.X Commerce
- All Varnish versions
Steps to reproduce
Prerequisites: Install and configure Varnish for your Magento store.
- Go to the store front.
- Browse through the store pages.
Observe that some content blocks, like the top navigation panel with categories, are not loading. Blank space is displayed instead.
All content and all page blocks load successfully.
The possible reasons for the issue are the following:
- ESI include tags are generated with HTTPS access protocol, while Varnish only works with HTTP.
- Varnish does not process ESI inside JSON.
- Response headers are too big for Varnish; it cannot process them.
To resolve the issues, you need to perform additional Varnish configuration and restart Varnish.
- As a user with
rootprivileges, open your Vanish configuration file in a text editor. See the Modify the Varnish system configuration section for info on where this file might be located for different operating systems.
- In the
DAEMON_OPTS variable, add
-p feature=+esi_disable_xml_check. This would look like:
bash DAEMON_OPTS="-a :6081 \ -p feature=+esi_ignore_other_elements \ -p feature=+esi_disable_xml_check \ -p feature=+esi_ignore_https \ -T localhost:6082 \ -f /etc/varnish/default.vcl \ -S /etc/varnish/secret \ -s malloc,256m"
- Save your changes and exit the text editor.
- In the VCL configuration file, increase the response headers by increasing the values of the these parameters:
workspace_backend. Make sure that the last two of them have similar values.
- When you change this, you need to run
service varnish restartfor the changes to take effect.