Tag Archives: CDN

CDNJS: The Missing CDN

The Google CDN is an awesome way to speed up page load times, but it only has a few of the most popular JavaScript libraries. That’s what CloudFlare is aiming to rectify with their CDNJS. They have a ludicrously long list of libraries—JavaScript, CSS, SWF, images, etc.—served over HTTP/HTTPS/SPDY.

Need 960gs, Twitter Bootstrap, Backbone.js, TinyMCE or something else entirely? They probably have it. If they don’t, you can open a pull request on GitHub to add it!

And since it’s backed by CloudFlare, it should be reliable. They know what they’re doing.

CDNJS — The Missing CDN [CloudFlare]

Automattic Releases Jetpack 2.0, Featuring the New Photon CDN

Automattic’s Jetpack plugin has certainly grown since I first looked at it. I originally dismissed it, not wanting to unnecessarily tie my own self-hosted blogs to WordPress.com for a few niceties like in-Dashboard traffic stats and very thorough spelling and grammar checking via After the Deadline.

I decided to try it out again now that it hit the big two-point-oh, and was surprised now only by the amount of functionality it offers, but by how many other plugins it can conceivably replace. The Publicize module, for instance, will automatically post links to new posts on Twitter, Facebook and other popular social networks, so you don’t need another plugin for that if you run Jetpack. I also found the Mobile Push Notifications and JSON API modules to be intriguing. The former sends push notifications to your iPhone/iPad when new comments are posted, and lets you jump right over to the WordPress iOS app to manage them, and the latter is primarily of interest to developers looking to integrate a WordPress blog into another web site or application. (Previously I used this plugin, but Jetpack looks roughly equivalent.)

The big new feature in this version is a free service called Photon, an “image acceleration and editing service” which acts as a CDN for your images. It mirrors images it finds in your posts (or ones a theme or plugin developer specifies via an API) on WordPress.com’s servers, which enables them to be served faster and takes load off your server. This would be excellent for blogs hosted on cheap shared hosting, especially if coupled with a static caching plugin like WP Super Cache or W3 Total Cache.

How Much Does Amazon CloudFront Cost for a Small Blog?

You may have heard about how people speed up their websites by offloading images, CSS and JavaScript from their server to a Content Delivery Network like Amazon CloudFront. The CDN mirrors the files in separate datacenters and serves them up from the one closest to a given user, which makes a noticeable difference to load times. If you use a plugin like W3 Total Cache, you can automatically link your media folders to a CDN and rewrite the the file URLs on the fly, even minifying the CSS and JavaScript.

Amazon CloudFront is one of the cheaper CDNs, but many people worry about it’s seemingly complicated pricing scheme. Since you pay for what you use, your monthly bill is calculated based on how many gigabytes of data you transfer and how many HTTP requests are made.

You pay $0.0075 for every 10,000 HTTP requests, and $0.12 per gigabyte for North American and European visitors. The cost-per gigabyte is slightly higher for other regions, but it doesn’t go over $0.25/GB.

So how much do you end up paying for a blog with around 40,000 page views per month? $0.64.

I’ve been running CloudFront for a little while now, and I ended up paying about sixty-four cents from the 3.004GB of transfer incurred over the month of January. It’s definitely affordable, and should help take some load off your server, besides decreasing load times.

Using Google-Hosted jQuery With a Local Fallback

Referencing commonly-used JavaScript libraries, like jQuery, stored on Google’s CDN is a good way to speed up your site. Many popular websites do so, which means the chances of a user having jQuery sitting in their browser cache already is pretty high. It doesn’t make a whole lot of sense to download it all over again for another website, does it? Using the copy on the Google Libraries CDN just makes a lot of sense.

But what if the servers Google has hosting it went down for some reason? Given Google’s track record, it’s not likely to be an issue, but it’s a good point. Fortunately, you can easily reference a backup. You can have a copy of jQuery on your server, and use a little bit of JavaScript to load it only if the Google one doesn’t load for some reason.

This little snippet, found in HTML5 Boilerplate, will do just that:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.6.4.min.js"><\/script>')</script>

This should even work with WordPress, if you put the second script line right before the </head> tag in your theme.

Google Launches Page Speed Service

Google recently launched a Page Speed Service, an offering along similar lines to CloudFlare. You set up a CNAME to point your domain to their servers, which cache your pages and serve them at blazing speed. They also run everything through the lines of mod_pagespeed to lower file sizes. It’s basically like a CDN for your entire website.

Page Speed Service is an online service to automatically speed up loading of your web pages. Page Speed Service fetches content from your servers, rewrites your pages by applying web performance best practices and serves them to end users via Google’s servers across the globe.

This is targeted mainly at people running small to medium sized websites, such as WordPress blogs, on shared hosting. The service takes the load off your server, so you don’t have to worry about it running slowly or going down from traffic.

Page Speed Service is currently in a trial period, where it’s free for anyone who wants to use it, but it may end up costing more in the future.

It will be interesting to see how this competes with CloudFlare, which offers more features and a free plan that is more than sufficient for most users. (You can pay $20/month for extra analytics and some more advanced features.) CloudFlare isn’t just trying to speed your site up, though. They also want to help protect it from DDoS attacks, email harvesting, and other unpleasantness. It already has quite a bit of traction.

Use Google-Hosted jQuery in Your WordPress Theme

How many sites use popular JavaScript libraries like jQuery? A lot. That’s why Google hosts many of them on their speedy CDN, so browsers only have to download jQuery or Prototype once in a day, instead of once per site.

How can your WordPress-powered site benefit from this? Digging into WordPress has the answer:

if ( !is_admin() ){
   wp_deregister_script('jquery');
   wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"), false, '1.3.2');
   wp_enqueue_script('jquery');
}

This little snippet goes in your functions.php, where it deregisters WordPress’s internal copy of jQuery and references Google’s. Unfortunately, it’s not set up for the handy no-conflict mode that lets you use Prototype scripts on the same blog.