CDN use cases#

The section provides additional information about working with the Cloud Files CDN services.

Purge CDN-enabled containers#

For a container to be purged from the CDN, you can either wait for the TTL to expire, or you can request that Rackspace remove, or purge, a CDN-enabled container from the network. After you have made the request to Rackspace through a support ticket, the system purges the container from the CDN, and sends an email to the address (or multiple addresses) that you indicate through the ticket. The email address notification is optional.

Note

To prevent the container from going back to the CDN, first change the X-CDN-Enabled flag to False as described in the operation to CDN-enable and CDN-disable a container at CDN-enable and CDN-disable a container.

CDN-enabled containers served through SSL#

A HEAD operation for a CDN-enabled container returns an SSL URI, X-Cdn-Ssl-Uri, in addition to the other headers associated with CDN. This feature enables you to use HTTPS protocol in URIs that are used for requesting objects stored in CDN-enabled containers.

Example: CDN-enabled container metadata: HTTP request

HEAD /v1/MossoCloudFS_0672d7fa-9f85-4a81-a3ab-adb66a880123/MyContainer HTTP/1.1
Host: cdn.clouddrive.com
X-Auth-Token: f064c46a782c444cb4ba4b6434288f7c

Example: CDN-enabled container metadata with SSL URI: HTTP response

HTTP/1.1 204 No Content
X-Cdn-Ssl-Uri: https://83c49b9a2f7ad18250b3-346eb45fd42c58ca13011d659bfc1ac1. ssl.cf0.rackcdn.com
X-Ttl: 259200
X-Cdn-Uri: http://081e40d3ee1cec5f77bf-346eb45fd42c58ca13011d659bfc1ac1. r49.cf0.rackcdn.com
X-Cdn-Enabled: True
X-Log-Retention: False
X-Cdn-Streaming-Uri: http://084cc2790632ccee0a12-346eb45fd42c58ca13011d659bfc1ac1. r49.stream.cf0.rackcdn.com
X-Trans-Id: tx82a6752e00424edb9c46fa2573132e2c
Content-Length: 0

Streaming CDN-enabled containers#

In addition to the other headers associated with CDN, a HEAD operation against a CDN-enabled container returns the following streaming URIs to enable the streaming feature:

  • X-Cdn-Streaming-Uri, which specifies a URI for video streaming that uses HTTP Dynamic Streaming from Adobe

  • X-Cdn-Ios-Uri, which specifies the URI for video streaming that uses HTTP Live Streaming from Apple

Streaming is a method of relaying data, such as video and audio material, over the network as a steady continuous stream, allowing playback to proceed while subsequent data is being received.

For information about streaming to iOS devices, see iOS streaming.

Example: CDN-enabled container metadata: HTTP request

HEAD /v1/MossoCloudFS_0672d7fa-9f85-4a81-a3ab-adb66a880123/MyContainer HTTP/1.1
Host: cdn.clouddrive.com
X-Auth-Token: f064c46a782c444cb4ba4b6434288f7c

Example: CDN-enabled container metadata with streaming URIs: HTTP response

HTTP/1.1 204 No Content
X-Cdn-Ssl-Uri: https://83c49b9a2f7ad18250b3-346eb45fd42c58ca13011d659bfc1ac1. ssl.cf0.rackcdn.com
X-Ttl: 259200
X-Cdn-Ios-Uri: http://fb1ca9de5ff9525ff6f8-64e65126753c56b595824f56d25789bb.iosr.cf1.rackcdn.com
X-Cdn-Streaming-Uri: http://084cc2790632ccee0a12-346eb45fd42c58ca13011d659bfc1ac1. r49.stream.cf0.rackcdn.com
X-Cdn-Enabled: True
X-Cdn-Ssl-Uri: https://2cb7edde3eac1dd66ea4-64e65126753c56b595824f56d25789bb.ssl.cf1.rackcdn.com
X-Cdn-Uri: http://081e40d3ee1cec5f77bf-346eb45fd42c58ca13011d659bfc1ac1. r49.cf0.rackcdn.co
X-Log-Retention: False
X-Trans-Id: tx82a6752e00424edb9c46fa2573132e2c
Content-Length: 0

iOS streaming#

The Cloud Files CDN allows you to stream video to iOS devices without needing to convert your video. After you CDN-enable your container, you have the tools necessary for streaming media to multiple devices. To leverage this ability, you must check the client’s user agent with JavaScript. An example of the user agent check and how to use it follows.

  1. CDN-enable your container. (See CDN-enable and CDN-disable a container.) Two streaming URIs are created: the container’s streaming URI (X-Cdn-Streaming-Uri) and its iOS streaming URI (X-Cdn-Ios-Uri).

  2. Perform a HEAD request against the CDN-enabled container to view these URIs.

  3. Link to your content in a HTML page by using a <video> element.

  4. Set the SRC attribute of the <video> element to the full streaming URI for your container plus the name of your content. In the following example, the streaming video is MobyDick.mp4.

    Example: HTML 5 video element

    <video width=”640” height=”480” id="videotag">
      <source src=”http://084cc2790632ccee0a12-346eb45fd42c58ca13011d659bfc1ac1.
      r49.stream.cf0.rackcdn.com/MobyDick.mp4” />
    </video>
    
  5. Add JavaScript to the <head> element of your HTML page to check if the user agent is an iOS device. If it is, the JavaScript should use the container’s iOS streaming URI (X-Cdn-Ios-Uri) instead of the regular streaming URI. The Cloud Files CDN delivers the properly formatted content for iOS devices only when the iOS streaming URI is used. In the following example, the JavaScript sets the <src> attribute of the <video> element videotag to the iOS Streaming URI. Remember to add your content’s name to the end of the iOS streaming URI.

    Example: JavaScript for user agent check

    <script type=”text/javascript”>
    
        function isIOS(){
            return ((navigator.userAgent.match(/iPhone/i)) ||(navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/
    i))) != null;
        }
    
        function init(){
            if (isIOS()){
               document.getElementById(“videotag”).src = “http://084cc2790632ccee0a12-346eb45fd42c58ca13011d659bfc1ac1.
               iosr.cf0.rackcdn.com/MobyDick.mp4”;
            }
        }
    
    </script>
    
  6. Add init() to the <body> element of your HTML page to call the user agent check when the page loads, as shown in the following example.

    Example: Load JavaScript in HTML page

    <body onload=”init()”>
    

With these pieces of code in place, the proper content streams are set for iOS devices.

CDN log delivery#

If you set the X-Log-Retention header on your CDN-enabled container to True, you enable CDN log delivery on that container. Then all the request logs generated by the edge nodes of the CDN provider to objects in this container are delivered into a special container created in your account named .CDN_ACCESS_LOGS. The delivered logs are in the same format as access logs (see Access log delivery). These logs, once delivered, are treated like any other object in your account, and you are charged for that storage.

You can use the CDN logs to analyze the number of requests for each object, the client IP address, and time-based usage patterns (such as monthly or seasonal usage).

Note

Delivery times vary greatly for CDN logs. In most cases, the logs are delivered within several hours, but delivery can sometimes take days. Cloud Files can only deliver the logs to you as fast as the logs are delivered from the CDN provider.

When you set the X-Log-Retention header to True on a CDN-enabled container, Cloud Files tracks every object in the container. If you have multiple containers that you want to track, you must set the X-Log-Retention header to TRUE for each container. When your first log is delivered, Cloud Files creates the .CDN_ACCESS_LOGS container. This container holds the CDN logs for every container for which you turn on logging. Log files exist until you delete them. To turn off logging, set the X-Log-Retention header to FALSE.

Log files are named according to the following pattern: container name, log date, log hour, and MD5 hash. For example:

Media/2014/07/01/16/096e6c4473f235db081deb51f42a8d98.log.gz

In this example, Media is the name of the container, 2014/07/01 is the date (July 1, 2014), and 16 is the hour that the log file was created. There might be multiple files for a given hour because the storage system splits log files based on both time and log file size. All times in the logs are UTC time. All logs contained in the log file are from the day and hour specified in the file name.

Within the gzip logs, the format of the entries is similar to National Center for Supercomputing Applications (NCSA) combined log format, but without cookies. The pattern follows. The dashes ( - ) denote fields that the NCSA combined log format dictates be present but that Cloud Files does not capture.

client_ip - - [day/month/year:hour:minute:second timezone] “method request           HTTP_version” return_code bytes_sent “referrer” “user_agent”

The following example shows log entries.

Example: CDN log entries

173.203.44.122 - - [15/07/2014:20:52:25 +0000] "GET
      /5142b6e5e57f760d7ff4-c591437fc634f2a98934b7738b8b8571.r93.cf1.rackcdn.
      com/image1.png HTTP/1.1" 304 277 "-" "Mozilla/4.0 (compatible;
      MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.
      50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0;
      InfoPath.3; .NET4.0C; .NET4.0E; MS-RTC LM 8; Microsoft Outlook 14.0.
      7109; ms-office; MSOffice 14)"
173.203.44.122 - - [15/07/2014:20:52:25 +0000] "GET
      /5142b6e5e57f760d7ff4-c591437fc634f2a98934b7738b8b8571.r93.cf1.rackcdn.
      com/ email.png HTTP/1.1" 304 278 "-" "Mozilla/4.0 (compatible;
      MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.
      50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0;
      InfoPath.3; .NET4.0C; .NET4.0E; MS-RTC LM 8; Microsoft Outlook 14.0.
      7109; ms-office; MSOffice 14)"
173.203.44.122 - - [15/07/2014:20:52:25 +0000] "GET
      /5142b6e5e57f760d7ff4-c591437fc634f2a98934b7738b8b8571.r93.cf1.rackcdn.
      com/ tiny-email.png HTTP/1.1" 304 277 "-" "Mozilla/4.0 (compatible;
      MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.
      50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0;
      InfoPath.3; .NET4.0C; .NET4.0E; MS-RTC LM 8; Microsoft Outlook 14.0.
      7109; ms-office; MSOffice 14)"
173.203.44.122 - - [15/07/2014:20:59:44 +0000] "GET
      /5142b6e5e57f760d7ff4-c591437fc634f2a98934b7738b8b8571.r93.cf1.rackcdn.
      com/ default.css?ver=3.8.3 HTTP/1.1" 200 17511 "http://www.rackspace.
      com/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML,
      like Gecko) Chrome/35.0.1916.153 Safari/537.36"
173.203.44.122 - - [15/07/2014:20:59:44 +0000] "GET
      /5142b6e5e57f760d7ff4-c591437fc634f2a98934b7738b8b8571.r93.cf1.rackcdn.
      com/ jquery.min.js?ver=3.8.3 HTTP/1.1" 200 8022 "http://www.rackspace.
      com/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML,
      like Gecko) Chrome/35.0.1916.153 Safari/537.36"