Export a Varnish configuration file
To export a Varnish configuration file from the Admin:
-
Click one of the export buttons to create a
varnish.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:
-
Back up your existing
default.vcl
. Then rename thevarnish.vcl
file you just exported todefault.vcl
. Then copy the file to the/etc/varnish/
directory.cp /etc/varnish/default.vcl /etc/varnish/default.vcl.bak2
mv <download_directory>/varnish.vcl default.vcl
cp <download_directory>/default.vcl /etc/varnish/default.vcl
-
Adobe recommend you open
default.vcl
and change the value ofacl purge
to the IP address of the Varnish host. (You can specify multiple hosts on separate lines or you can use CIDR notation as well.)For example,
acl purge { "localhost"; }
-
If you want to customize the Vagrant health checks or grace mode or saint mode configuration, see Advanced Varnish configuration.
-
Restart Varnish and your web server:
service varnish restart
service httpd restart
Cache Static Files
Static files should not be cached by default, but if you want to cache them, you can edit the section Static files caching
in the VCL to have the following content:
# Static files should not be cached by default
return (pass);
# But if you use a few locales and do not use CDN you can enable caching static files by commenting previous line (#return (pass);) and uncommenting next 3 lines
#unset req.http.Https;
#unset req.http./* {{ ssl_offloaded_header }} */;
#unset req.http.Cookie;
You must make these changes before you configure Commerce to use Varnish.