Should You Use a Content Delivery Network?
If you’ve been following my recent posts, 7 Reasons to use a Content Delivery Network and 7 Reasons NOT to use a Content Delivery Network, you’ll be utterly confused and on the brink of giving up this web game altogether.
The answer to “should I use a CDN?” is…
There are a few clear-cut situations when a CDN should be avoided:
- You’re building an intranet application without external access to the internet.
- Security or privacy is a top priority, e.g. a banking application where you need full control over all source files and server locations.
- You’re building an application for a company or country which is known to block specific domains or IP address ranges.
Your choice of CDN will also be more limited if your application requires the secure HTTPS protocol.
CDNs bring fewer benefits to smaller sites with relatively light traffic. Assuming you don’t require high-bandwidth video or audio files, it may be simpler to keep all your files in one place.
Small Local vs Large CDN Files
I’d be tempted to pick the smaller local file — especially if a reasonable proportion of the target audience are using mobile devices. A smaller file outweighs many of the reasons to use a CDN; it will download quicker and execute faster.
A/B Performance Testing
A CDN may be less efficient if, for example, the majority of users are on slower connections and are physically close to your main server’s location.
The Best of Both Worlds?
Several of the problems associated with CDNs can be rectified using a fall-back. If a file cannot be downloaded because the CDN is blocked or unavailable, the system can resort to a local version. Again, this requires more development but would increase availability on mission-critical systems.
CDNs and Progressive Enhancement
Consider web fonts. Google’s webfont CDN is a great system and you’ll encounter few problems if the service becomes unreliable or fails. If the font can’t be loaded, the site can fall-back to a common typeface.
CDNs are an incredibly useful resource but remember to consider the consequences. In practice, most sites will benefit if they load jQuery, the HTML5 shim and font files from a public CDN. For busier sites, the speed improvements and cost savings of a private CDN are hard to ignore.