SnapShooter Backups Server, Database, Application and Laravel Backups - Get fully protected with SnapShooter

Server testing using curl

Project curl is a command-line tool that is used to do Internet transfers for resources specified as URLs using Internet protocols. You can read more about its history at https://ec.haxx.se/.

In this tutorial, we learn about using curl to do some simple server testing.

Examine response header

To verify if a proxy server cache is working, we can check the response's header "x-proxy-cache" value.

Examine response header using curl:

curl -I https://yoursite.com

Output:

HTTP/2 200 
server: nginx/1.14.0
date: Sat, 03 Aug 2019 05:44:27 GMT
content-type: text/html; charset=UTF-8
expires: Thu, 8 Aug 2019 05:44:27 GMT
cache-control: public, max-age=432000
last-modified: Sat, 3 Aug 2019 05:43:27 GMT
x-ua-compatible: IE=Edge
x-proxy-cache: MISS

Show response time

Response time is a simple yet straightforward metric to benchmark when optimizing our site.

To check response time using curl:

curl -s -w "%{time_total}\n" -o null https://yoursite.com

Options: + -s: run it in silent mode. Do not show progress info. + -w: format the output string using a placeholder. + -o: write the output to a file. Here we discard it by writing to null.

Send request header

When we need to send "no-cache" request to the header to test the proxy cache server. We can do so via curl too.

Send request header using curl:

curl -H 'Cache-Control: no-cache' -I https://yoursite.com

Output:

HTTP/2 200 
server: nginx/1.14.0
date: Sat, 03 Aug 2019 06:27:49 GMT
content-type: text/html; charset=UTF-8
expires: Thu, 8 Aug 2019 06:27:49 GMT
cache-control: public, max-age=432000
last-modified: Sat, 3 Aug 2019 06:26:49 GMT
x-ua-compatible: IE=Edge
x-proxy-cache: BYPASS

End

We hope this simple tutorial helped you with your development.