Varnish Magento2 Configuration

  1. Install Varnish on the server
  2. Acquire a Magento VCL file using bin/magento varnish:vcl:generate
  3. Store the VCL file in /etc/varnish
  4. Enable use of Varnish cache in Admin > Stores > Configuration > System > Full Page Cache > Caching Application
    • update core_config_data set value = 2 where path = "system/full_page_cache/caching_application"
  5. Check the Varnish Configuration section's connection details
  6. Check HTTP headers for x-magento-cache-debug HIT


Large Header size issues can be potentially solved looking here

Increasing the workspace size can cause varnish to run out of memory. This can be confirmed by running the following

varnishlog | grep abandoned

If you see the following, then varnish has panicked. Log abandoned

Possible solutions

  • The workspace needs to be big enough for the largest category to fit comfortably within it
  • Customise Magento to make the headers smaller