API to Check HTML headers for X-Varnish and X-Cache
To access the API simply send a GET request to https://isvarnishworking.co.uk/api/url-test.php passing the url variable and the API will return a json array response with true and false statements for each of the header categories.
https://isvarnishworking.co.uk/api/url-test.php?url=https://oliverwhysall.co.uk
Response:
{ "url": "https://oliverwhysall.co.uk", "headers": { "varnish": true, "cache": true, "other": true }, "fetched": "2022-06-27 13:50:50", "success": true }
https://isvarnishworking.co.uk/api/url-test.php?url=
Response:
{ "error": "No URL provided", "success": false, "fetched": "2022-06-27 13:50:50" }
https://isvarnishworking.co.uk/api/url-test.php?url=https://party.com
Response:
{ "error": "There was a problem accessing this URL.", "success": false, "fetched": "2022-06-27 13:50:50" }
To add an array to the response to add all headers simply add the variable showall=true to the request
https://isvarnishworking.co.uk/api/url-test.php?url=https://oliverwhysall.co.uk&showall=true
Response:
{ "url": "https://oliverwhysall.co.uk", "headers": { "varnish": true, "cache": true, "other": true }, "fetched": "2022-06-27 13:50:50", "success": true, "allHeaders": [ "HTTP/1.1 200 OK", "Server: nginx", "Date: Thu, 24 Jun 2021 21:57:27 GMT", "Content-Type: text/html; charset=UTF-8", "Content-Length: 5676", "Connection: close", "Vary: Accept-Encoding", "X-Powered-By: PHP/7.3.25", "X-UA-Compatible: IE=edge", "X-Content-Type-Options: nosniff", "Expires: Fri, 25 Jun 2021 00:10:51 GMT", "Cache-Control: public, max-age=180, stale-while-revalidate=360, stale-if-error=43200", "X-Varnish: 525498 34509", "Age: 13596", "Via: 1.1 varnish-v4", "X-Cache: HIT", "X-Cache-Hits: 97", "X-OW: oliverwhysall.co.uk", "Accept-Ranges: bytes" ] }