Magento2 and Varnish: the ideal pairing for an online shop
With Varnish Cache, cached pages are served without even reaching the Magento2 server, so its architecture no longer slows you down.
Magento2 is the world leader in e-commerce solutions. Its rich functionality and stability are well proven. Magento2’s architecture makes it even easier to add extra modules (also called “extensions” or “plugins”) while keeping the system stable. When these extensions are well developed, integrating them into a Magento2 site is very easy. You can add a “loyalty points” module, or switch to another carrier or payment solution, in a few hours of work, whereas the same job would take days, weeks or even months on a custom-built solution.
On the other hand, this strict, modular architecture can be more resource-hungry if it is not implemented properly. Magento2 offers many features to optimise its performance. Varnish Cache is one of them. Varnish Cache is an open-source “website accelerator” (also known as a caching HTTP reverse proxy). When Magento2 is configured correctly and full page cache is enabled, each page is generated and stored the first time a visitor views it. When that visitor, or another one, then (re)visits the page, the stored version is delivered straight to the browser.
Varnish Cache stores and delivers these pre-generated pages, making them even faster for the visitor. With Varnish Cache, the visitor’s request never even reaches the Magento2 server: the Varnish server delivers the requested page directly.
Only a few small scripts, such as the one that shows the number of items in the cart, then run once the page has loaded, for an optimal user experience.
On a correctly configured Magento2 site running Varnish Cache, page delivery is therefore no longer affected at all by Magento2’s modular architecture: it depends only on the internet connection and the weight of the page’s HTML.
Published 6 Nov 2020
A question about this article?
30 minutes, no strings attached, with a senior technical contact.