Export a Varnish configuration file

To export a Varnish configuration file from the Admin:

  1. 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:

    Configure Commerce to use Varnish in the Admin

  2. Back up your existing default.vcl. Then rename the varnish.vcl file you just exported to default.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
    
  3. Adobe recommend you open default.vcl and change the value of acl 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";
     }
    
  4. If you want to customize the Vagrant health checks or grace mode or saint mode configuration, see Advanced Varnish configuration.

  5. 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.

Previous pageWeb server
Next pageAdvanced Varnish configuration

Commerce