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
TIME REQUIRED 5 min
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 http://127.0.0.1/

Replacing 127.0.0.1 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.


Помогла ли вам эта статья?
Благодарим вас за отзыв. Чтобы связаться с сотрудником службы поддержки клиентов, позвоните по номеру этой службы или воспользуйтесь опцией чата выше.
Мы рады вам помочь! У вас остались вопросы?
Приносим извинения. Расскажите нам, какие затруднения вы испытываете или почему рекомендованное решение не помогло устранить проблему.