Tuesday, June 7, 2016

Using Microsoft OneDrive 2016 as Content Delivery Network (CDN)

For web developers who are mindful of Page Speed scores, finding a free Content Delivery Network (CDN) to load your static content from a cookie-free domain is a nice to have!!!

This is a examination of using Micorosoft OneDrive as a possible CDN. I will test this using
https://onedrive.live.com to hosting a 
ASCIIfy-StarFunv2.gif a 2.06 KB GIF image.  

One caveat off the top is that 
OneDrive is a COOKIE domain and requires authentication to get it's public resources, but that has change as of June 1, 2016 as part of new API change.
In fact, if you use the "Share Link" in OneDrive this uses a cookie to authenticate and will drastically reduce speed to grab the resource, you can read all about that in my old post here.

But the API has change as of June 1, 2016 and now the "Embed Link" uses a different url scheme and still does use a cookie, but it's working much quicker. 

Here's how to get the embed link for a resource on OneDrive. 

For more information on how to get a link to use in your website page for testing, read my blog entry on Microsoft OneDrive Direct File Download URL Maker.

Now lets examine some network timings from Google Chrome Inspect window.

Now you notice 4 different timings, and they each have the following URLS

  1. stripped parameters from url
  2. Original Embed Link code (Copy the to embed image url in 1st image)

  3. Using http instead of https

  4. redirected from 3 (to https//:)
  5. tried 1 as http:// and resulting in a redirect as well, so insignificant result.


  1. Stripping the Embed Link of ?width=85&height=85&cropmode=none, permitted getting the original gif, produced the best results. You'll noticed that image took a swift 226 ms to grab the ASCIIfy-StarFunv2.gif  and that rivals many CDNs!
  2. Using the original Embed link with the ?width....code transformed the gif to a sized jpeg! This nearly double the request time.
  3. Here I attempted to use http:// request and was redirect to 4
  4. Uses https and has simliar timings and equivalent to 2. So no saving using http, always redirects to https


OneDrive can be used as an effective free Content Delivery Network (CDN) to load your static content. 

No comments:

Post a Comment