Uploading custom VCL

  Last updated November 13, 2019

Fastly allows you create your own Varnish Configuration Language (VCL) files with specialized configurations. By uploading custom VCL files, you can use custom VCL and Fastly VCL together at the same time. Keep in mind that your custom VCL always takes precedence over VCL generated by Fastly.

Uploading a VCL file

Follow these instructions to upload a custom VCL file:

  1. Log in to the Fastly web interface and click the Configure link.
  2. From the service menu, select the appropriate service.
  3. Click the Edit configuration button and then select Clone active. The Domains page appears.
  4. Click the Custom VCL tab. The Custom VCL page appears.
  5. Click the Upload a new VCL file button. The Upload a new VCL file page appears.

    the default upload a new VCL file page

  6. In the Name field, enter the name of the VCL file. For included files, this name must match the include statement in the main VCL file. See how to include additional VCL configurations for more information.
  7. Click Upload file and select a file to upload. The name of the uploaded file appears next to the button.

  8. Click the Create button. The VCL file appears in the Varnish Configurations area.
  9. Click the Activate button to deploy your configuration changes.

Editing a VCL file

To edit an existing VCL file, follow these instructions:

  1. Log in to the Fastly web interface and click the Configure link.
  2. From the service menu, select the appropriate service.
  3. Click the Edit configuration button and then select Clone active. The Domains page appears.
  4. Click the Custom VCL tab. The Custom VCL page appears.
  5. In the Varnish Configurations area, click the VCL file you want to edit. The Edit an existing VCL file page appears.

    edit vcl file in the varnish configurations area

  6. In the Name field, optionally enter a new name of the VCL file.
  7. Click the Download link to download the appropriate file.
  8. Make the necessary changes to your file and save them.
  9. Click the Replace file button and select the file you updated. The selected file replaces the current VCL file and the file name appears next to the button.
  10. Click the Update button to update the VCL file in the Fastly application.
  11. Click the Activate button to deploy your configuration changes.

Including additional VCL configurations

To make your full VCL configuration easier to maintain, you can split it up into multiple files that are accessed by a main VCL file. This allows you to separate out chunks of logic (for example, logic that has a specific purpose or that might change frequently) into as many separate files as makes sense.

  1. Start by isolating a portion of VCL and placing it in a separate file. The name of the file doesn't matter, nor does the file extension. A foo.vcl file will work just as well as a bar.txt file.
  2. Upload the file to include it in your Varnish configurations and give it a unique name when you fill out the Name field at the time of upload (for example, you could call it Included VCL). The uploaded file will appear in the Varnish Configurations area along with your main VCL file.

    an example main vcl file in the varnish configurations area that's been designated as the main vcl

  3. Enter the name of the included VCL file on a separate line in the main VCL configuration file. For example, your Included VCL file would get added to the main VCL file in a single line like this:

    1
    
    include "Included VCL";
    
  4. Continue uploading VCL files and then including them in your main VCL using the syntax include "<VCL FILE>"; where <VCL FILE> exactly matches the name you entered in the Name field.
Back to Top