Geeking out with WordPress, CDNs, and Amazon CloudFront

It is truly amazing how powerful and sophisticated WordPress is becoming. Even better, much of this functionality is available from free plugins and themes. (The developers of such products can make money by doing support, custom work, etc., after giving away the main product and building a user base.)

Here’s an example, using the disk cache program and theme that Polizeros uses. This blog was hitting compute cycle limits at Laughing Squid, where it is hosted. They said it was due to excessive database hits on the server while loading pages. I deactivated various plugins. monitored the results, but that didn’t help much.

Then, I discovered that the theme I use, the highly configurable Atahualpa, has an option to put CSS and JavaScript inline rather than external, plus you can compress CSS. I turned these options on. Google Page Speed went to 94 from 90. Okay, now we’re starting to get somewhere.

Home of W3 Total Cache

I then contacted W3 Total Cache and paid them to examine my cache settings. I had also just implemented Amazon S3 for storing data and images. They tweaked a few settings then advised me to use Amazon CloudFront on top of S3. W3TC has full support for both.

This is where it gets really powerful. Amazon S3 stands for Simple Storage Service. W3TC uploads all the images, CSS, JavaScript, and theme files from Laughing Squid to Amazon S3 where they are hosted, thus dropping load on Laughing Squid. CloudFront is a layer on top of S3 which takes the files from S3 and distributes them to servers across the planet. So, if someone in Scotland views Polizeros, much of it will be coming to them from the Amazon CloudFront site in London and not coming from the US. This obviously speeds things up for them.

S3 and Cloudfront are part of Amazon Web Services

Best of all, Amazon Web Services are pay as you go with no minimum fees. Everything I’ve just described might cost me 20 cents a day. Blogging has come a long way.

The Atahaulpa theme is amazing. It has 28 pages of configuration items. You can make hundreds of changes to the theme from the Dashboard. There’s no need to go mucking around in code. The entire look and feel of a blog can be changed in three minutes without touching code. But, and this is crucial, you do need to know what you are doing! You may not have to change code but understanding what it does and how a WordPress theme works is crucial.

W3TC has nine pages filled with complex configuration choices. It was written by Frederick Townes originally as the cache for giant tech site Mashable and then turned into a WordPress plugin.

Both of these fine products are free. That’s what makes open source so powerful and vibrant, large communities building software for the betterment of all.

As for those compute cycles, they dropped sharply after I went to S3 and CloudFront.

WordPress Plugins are getting sophisticated and powerful


In the past few months I’ve really ramped up using WordPress plugins, and they do some amazing things. All but two are free.

AddToAny is the widget at the end of each post which lets you share it on dozens of sites. I use it myself to to post to Twitter, Facebook, and Stumbleupon.

After the Deadline. Spell and grammar checker. Highly useful.

Akismet. Kills spam comments. Essential.

All in One SEO. Definitely improves visibility on search engines and does so completely ethically.

Backup Buddy. Backs up the database or the entire site and FTPs it to the Amazon S3 cloud. Fully automated. $45 and totally worth it.

FD Feedburner plugin. Takes all possible version of your main RSS and redirects them to Feedburner. This way someone subscribing to the RSS feed always gets Feedburner.

Pubsubhubbub. Instantly sends new posts to a cloud hub where they get picked up fast. With this, new posts on Polizeros literally appear in my Google Reader RSS feed 5 seconds later.

W3 Total Cache. The best cache around. 8 pages of configuration items (!) Be ready to spend some time learning it. Hint: If you are on a shared server, do not use database or object caching. It dramatically cut the load time here.

WordPress.com Stats. A great way to track how many people are on the site. Appears in the Dashboard.

WPTouch Pro. Displays the site in a mobile format for iPhone / iPad / Android / Blackberry. If using W3 Total Cache, you must allow and disallow various user agents in order for WPTouch Pro to work right. Both plugins explain what to do. $25 and also worth it.

What plugins do you use?

Speed up WordPress with W3 Total Cache


W3 Total Cache is an amazing, free WordPress plugin that when configured optimally results in WordPress blogs loading much faster, like this one.

If you want to view the home page in WordPress, it normally runs a PHP script, opens the database, populates the page with the data, then presents it to the viewer. If you have 10 (or 100 or 1,000) simultaneous readers, it does the exact same thing each time, which puts a big load on the server and is duplicated effort. A cache writes the home page to disk as HTML and presents that to readers, which takes vastly less resources and is much faster. If the home page changes, it simply re-writes the cached page.

W3 Total Cache does that, and much more. It has database, object, and browser caches as well as page caches, and eight tabs of highly detailed settings, which can be intimidating at first. I highly suggest reading Install and configure W3 Total Cache in 7 easy steps, which walks you through the process (45 page PDF on Scribd)

It also has Minify, which strips unneeded blank space, comments, and line breaks from HTML, JavaScript, and CSS, cutting down on the size of pages sent to browsers. This is one of the more involved options. I advise doing the others first, then this. If you do a View Source on this home page, you’ll see that the code is mushed together with Minify.

If your blog is on a shared server, disable Database Cache and Object Cache, as they say it can actually slow things down. Once I did that here, load times became much faster.

Polizeros is now getting load times of 2-3 seconds, and that’s because of W3 Total Cache. I highly recommend it for any WordPress blog.

Download W3 Total Cache from WordPress.

Polizeros caching software change

Warning: The post is deeply geeky.

Polizeros is now running W3 Total Cache. You may notice the site is loading faster. (There were a few hiccups earlier in the day while installing it but those have been resolved.)

Caching software makes copies of frequently used pages, like the Home Page, then serves them up to those browsing the site. So, rather than WordPress having to load the php page, pull data from the database, then render the page, it simply uses the cached copy. This greatly cuts down on server usage and load, especially when you have hundreds of simultaneous users.

I switched caching software at the recommendation of Laughing Squid, our hosting company. Polizeros was bumping up against a compute cycles limit, which is the amount of processor time being used. They analyzed the site and said W3 is more powerful than the cache I was using and should help.

They may have a funny name, but Laughing Squid is the best host I’ve used. They host everything in the Rackspace Cloud. I can’t remember having downtime, and their tech support is superb. After some weird glitches trying to install W3 – which turned out to be a PHP memory limit issue – I emailed them and they did it for me.

Even better, if Polizeros does exceed the limits for the account, they simply upgrade the site in $4 a month increments so everything keeps going rather than blocking the site as some hosts do. That’s a big advantage of cloud computing. It scales as needed. Rackspace doesn’t do hosting for small sites per se, so that’s why I use Laughing Squid.

Big thanks to Jamie Holly at Intoxination for advice and help. If you ever get a 500 Server Error on your site or blog, check your .htaccess file, because that’s probably where the problem is. And make sure all remnants of the old cache are gone before installing the new one, otherwise a festive and alarming set of error messages may ensue.