In my “Six Things You Need To Know If You’re Starting A WordPress Blog” post from a couple of months ago, one of the non-essential but beneficial improvements I suggested was to install a caching plugin like W3 Total Cache. Caching helps make a WordPress site faster, but there’s a way to make it even faster still — you can turn it into a completely static site.
If you’re a follower of this blog, you’ll know that we’ve talked about static sites often, usually in the context of static site generators like Jekyll. I’m a fan of static site generators, because I like to encourage people to ditch the content management systems that put a layer between them and the technology they’re using. But, static site generators aren’t for everyone, and for anything more than a personal blog or portfolio site, they’re lacking in much needed functionality. A major reason we use content management systems in the first place is to make it easier to handle more complex publishing workflows, and static site generators aren’t great for that.
But the major benefit of a static site is that it’s blazingly fast. WordPress is essentially a dynamic site generator with content management functionality. By default, it generates every page that a user requests by executing PHP scripts that query a MySQL database. WordPress isn’t slow as content management systems go, but because it builds pages on-the-fly, it’s slow compared to a static site. Caching is a sort of halfway house between static sites and fully dynamic sites — caching systems store some of the objects used to build a page so that they don’t have to be rebuilt with every page request.
For the most part, pages don’t need to be created on the fly. Your blog articles don’t need to be different from one visitor to the next, so rebuilding the page is just a waste of time. Caching plugins take advantage of this to serve pages more quickly.
Caching plugins are selective about what they cache. Frequently, there is content on a page that we want to be dynamic: Twitter widgets, comments, and the like. If caching plugins cached everything for a long time, comments wouldn’t update.
Turning WordPress into a static site is essentially a form of very aggressive caching; everything is cached for a predetermined period, and nothing is generated on-the-fly. It’s worth noting that if you want some elements of your page to be dynamic, then very aggressive caching isn’t going to work for you. But, if you have a portfolio site, lead generation site, or blog site that doesn’t include dynamic content, then aggressive caching to create a static site is a viable performance optimization technique.
The benefit of using WordPress to create a static site is that you get the speed benefits of static pages, but you don’t have to give up WordPress’ content management features.
Before I get to how you can change your WordPress site into a static site, I want to clear up a potential cause of confusion. In the WordPress world, “static homepage” is the term used to refer to a homepage that doesn’t display the default blog listing. That’s not what we’re talking about here. We’re talking about long-term caching of all page content — it doesn’t matter what configuration the homepage has.
There are number of plugins created to turn a WordPress installation into a static site, but the one I’ve had most success with is Really Static.
(1=No Cache,2=WP Super Cache,3=really static)
Basic setup is straightforward and well-explained. Really Static generates HTMl pages every time you publish or update a post or page. In the simplest configuration, you can just use those files as they are from your WordPress hosting account, but if you want to use WordPress as a local static site generator and move the resulting files to another server via FTP, the plugin can handle that too. A particularly useful aspect of Really Static is that it will regenerate the static pages whenever a comment is published, which means you can have static pages with functioning comments.
Using WordPress for static site generation isn’t for everyone; the vast majority of WordPress users should stick with simply using a caching plugin, but if your site could benefit from faster loading times and has no need for WordPress’ dynamic features, it’s worth considering.