The way to make this work without installing a plugin involves understanding how your Magento application is put together.
There are 2 components that make up your Magento site:
- Static content - This could be images, CSS, JS or even generic HTML documents
- Dynamic/Personalised content - This is content that changes for each user - eg. The number of items in someones cart. This is something that cannot be shared amongst multiple users
You need a strategy to let Varnish cache all static content (including generic HTML pages) and then load dynamic content another way.
Varnish implementation options:
There are 2 main methods of implementing HTML document caching:
- Loading personalised elements of the page via additional requests after the page has loaded. A common implementation method here is to use AJAX to request page elements that are personalised. This means that the HTML document itself becomes cacheable across the board and lightweight AJAX calls fetch the personalised information.
- Varnish supports a technology called ESI (Edge Side Includes) that allows different parts of a HTML document to be cached differently.
Disclaimer - we run cloud Varnish instances with full metrics/logs for Magento at www.section.io but for Magento specifically we do recommend the Nexcess Turpentine module as the work involved in removing personalised to Ajax calls can be indepth and Turpentine is a quick win.
In good news, Magento 2 supports Varnish out of the box as its preferred caching solution so all of the hard work has been done to load personalised content via AJAX!