On this page

Varnish as HTTP Cache

Overview

Varnish is a HTTP proxy-cache, which works as a reverse proxy between your application and the client. Following rules defined by the user, Varnish will cache the data of an application to reduce the load on its server. We use Varnish 6.6.0 and varnish-modules 0.18.0.

Limitations

Enable Varnish for your application

To enable it, you just have to create a varnish.vcl file in the /clevercloud folder. This file describes how Varnish caches your applications and how it decides to return a cached resource or not.

To know how to write your varnish.vcl file, please have a look at the Varnish 6 book.

Listen on the right port

Once varnish is enabled, your application should no longer listen on port 8080, but on port 8081. Because it’s Varnish that will listen on port 8080, and it will have in its configuration your application as backend.

Configure the cache size

You can change the storage size specified in the varnish.params file with the CC_VARNISH_STORAGE_SIZE environment variable (the default value is 1G).

CC_VARNISH_STORAGE_SIZE=2G

Varnish 6 migration

If you already have a configuration for an older version of varnish, you can read this guide to upgrade to version 6.

Example files

We provide some examples of Varnish configuration files that you can use for your application. Create a /clevercloud folder at the root of your application if it does not exist, rename the file to varnish.vcl and move it in the /clevercloud folder.

Comments