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 strong> | Basic - 1 | Medium - 2 | Advanced - 3 td> |
TIME REQUIRED strong> | 5 min |
RELATED PRODUCTS strong> | 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 -
CentOS -
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.
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.
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:
Via: 1.1 varnish-v4
That is it, you have verified the functionality of Varnish on your server.