How to test Varnish using cURL

This article will show you how to test Varnish by analyzing the HTTP headers you receive from the cURL command. There are a multitude of other ways to test this, but I find using cURL to be the easiest.

DIFFICULTY Basic - 1 | Medium - 2 | Advanced - 3
RELATED PRODUCTS Linux-based VPS or dedicated servers

Testing varnish is crucial to ensure your websites are being cached and served in a timely matter, here is a quick test to ensure Varnish is working.

First, log in to any server that has cURL installed, if it is not installed you can easily install it running:

Ubuntu -

apt-get install curl

CentOS -

yum install curl

Once cURL is installed, you can then test Varnish by analyzing the headers, we will use the capital I flag to retrieve only the headers.

curl -I

Replacing with a domain that is hosted on your server, or if you are testing from the default document root - use your server IP. You should see a similar output depending on your configuration.

HTTP/1.1 200 OK
Date: Tue, 18 Nov 2014 19:05:29 GMT
Server: Apache/2.4.7 (Ubuntu)
Vary: Accept-Encoding
Content-Type: text/html;charset=UTF-8
X-Varnish: 16
Age: 0
Via: 1.1 varnish-v4
Connection: keep-alive

Two key flags that you want to pay attention to that let you know Varnish is indeed working correctly:

X-Varnish: 16
Via: 1.1 varnish-v4

That is it, you have verified the functionality of Varnish on your server.

Var den här artikeln till hjälp?
Tack för din feedback. Ring vårt supportnummer eller starta chattalternativet ovan om du vill prata med en medarbetare på kundtjänst.
Vi är glada att vi kunde hjälpa till! Finns det något mer vi kan göra för dig?
Det var tråkigt att höra. Berätta vad som var krångligt eller varför lösningen inte hjälpte dig med problemet.