cURL is a powerful command-line tool widely used for testing and troubleshooting client-server data transfer over HTTP/HTTPS.
By using a series of command-line flags, you can test your CDN service.
(HTTP FTP FILE) Fetch the headers only! HTTP-servers feature the command HEAD which this uses to get nothing but the header of a document. When used on an FTP or FILE file, curl displays the file size and last modification time only.
(HTTP) If the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code), this option will make curl redo the request on the new place. If used together with -i, –include or -I, –head, headers from all requested pages will be shown. When authentication is used, curl only sends its credentials to the initial host. If a redirect takes curl to a different host, it won’t be able to intercept the user+password. See also –location-trusted on how to change this. You can limit the amount of redirects to follow by using the –max-redirs option.
Makes curl verbose during the operation. Useful for debugging and seeing what’s going on “under the hood”. A line starting with ‘>’ means “header data” sent by curl, ‘<‘ means “header data” received by curl that is hidden in normal cases, and a line starting with ‘*’ means additional info provided by curl.
$ curl -IL http://11131-1.b.cdn12.com/sample.mp4 HTTP/1.1 200 OK Server: ucdn Date: Thu, 07 May 2020 11:52:29 GMT Content-Type: video/mp4 Content-Length: 1804076 Connection: keep-alive Keep-Alive: timeout=20 Last-Modified: Wed, 15 Apr 2020 17:57:18 GMT Etag: “60df82646f4bedd777446e75f4305da8” X-Timestamp: 1586973437.14001X-Trans-Id: tx34e73eba3210470e90837-005eb3f67d X-Served-From: origin Expires: Sat, 17 Oct 2020 19:37:40 GMT Cache-Control: max-age=14111111 Access-Control-Allow-Origin: * Access-Control-Allow-Methods: HEAD, GET, OPTIONS Accept-Ranges: bytes
Is your content served by the Universal CDN?
By using the command above (curl -IL) and by replacing http://example.ucdn.com/sample.mp4 with an URL of the file of yours (http(s)://URL_to_your_file.com) you can determine if the content is served by UCDN or by the origin server (A Web server that contains the original Web page. The term is used to identify the Web server from the cache server.)
HTTP/1.1 200 OK – shows that the request has succeeded.
In the example above the “X-Served-From” header is showing that the asset is served by the origin (X-Served-From: origin). This means that this was the first request for this asset after the integration of the CDN services and that the asset has not been cached, yet.
Learn more about HTTP status codes at https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
Server: ucdn – shows that the file has been served by UCDN
-v flag is very useful for debugging and seeing what’s going on “under the hood” and will provide us with additional information that will assist us in troubleshooting:
$ curl -ILv http://11131-1.b.cdn12.com/sample.mp4 * Trying 184.108.40.206… * TCP_NODELAY set * Connected to 11131-1.b.cdn12.com (220.127.116.11) port 80 (#0) > HEAD /sample.mp4 HTTP/1.1 > Host: 11131-1.b.cdn12.com > User-Agent: curl/7.58.0 > Accept: */* > < HTTP/1.1 200 OK HTTP/1.1 200 OK < Server: ucdn Server: ucdn < Date: Thu, 07 May 2020 13:23:26 GMT Date: Thu, 07 May 2020 13:23:26 GMT < Content-Type: video/mp4 Content-Type: video/mp4 < Content-Length: 1804076 Content-Length: 1804076 < Connection: keep-alive Connection: keep-alive < Keep-Alive: timeout=20 Keep-Alive: timeout=20 < Last-Modified: Wed, 15 Apr 2020 17:57:18 GMT Last-Modified: Wed, 15 Apr 2020 17:57:18 GMT < Etag: “60df82646f4bedd777446e75f4305da8” Etag: “60df82646f4bedd777446e75f4305da8” < X-Timestamp: 1586973437.14001 X-Timestamp: 1586973437.14001 < X-Trans-Id: tx34e73eba3210470e90837-005eb3f67d X-Trans-Id: tx34e73eba3210470e90837-005eb3f67d < Expires: Sat, 17 Oct 2020 19:37:40 GMT Expires: Sat, 17 Oct 2020 19:37:40 GMT < Cache-Control: max-age=14105654 Cache-Control: max-age=14105654
< X-Served-From: l1X-Served-From: l1
< Access-Control-Allow-Origin: * Access-Control-Allow-Origin: * < Access-Control-Allow-Methods: HEAD, GET, OPTIONS Access-Control-Allow-Methods: HEAD, GET, OPTIONS < Accept-Ranges: bytes Accept-Ranges: bytes
In the example above the “X-Served-From” header is showing that the asset is served by the Universal CDN edge servers (X-Served-From: l1 or X-Served-From: l2 ). This means that this was not the first request for this asset after the integration of the CDN services and that the asset had been already cached.