Configure Magento to use Varnish
To configure Magento to use Varnish:
- Log in to the Magento Admin as an administrator.
- Click STORES > Configuration > ADVANCED > System > Full Page Cache
- From the Caching Application list, click Varnish Caching
- Enter a value in the TTL for public content field.
-
Expand Varnish Configuration and enter the following information:
Field Description Access list Enter the fully qualified host name, IP address, or Classless Inter-Domain Routing (CIDR) notation IP address range for which to invalidate content.
Backend host Enter the fully qualified host name or IP address and listen port of the Varnish backend or origin server; that is, the server providing the content Varnish will accelerate. Typically, this is your web server.
Backend port Origin server's listen port. - Click Save Config.
-
Click one of the export buttons to create a
default.vcl
you can use with Varnish.For example, if you have Varnish 4, click Export VCL for Varnish 4
The following figure shows an example.
- Replace your existing
default.vcl
with the one you just exported. -
Restart Varnish and your web server:
service varnish restart service httpd restart
Find us on