How to quicken your site's webpage load time

Dump your CMS for static webpage generators

usain bolt winning fastest record
PhotoBobil (CC BY 2.0)

If you run a website of any significant size, odds are you utilize some form of content management system (CMS). Wordpress, Drupal, or the like.

And, if you don’t use such a system, you probably employ rather extensive use of some form of server-side, scripted, page generation. PHP, ASP, Ruby… the list goes on and on.

There are many scenarios where such a system makes a great deal of sense. But I’m here to tell you, right now, that it is highly unlikely that you actually need them… at least for the majority of your page. And, what’s more, if you migrate away from a CMS system you can not only make your webpages smaller and faster-loading for your visitors… but you can save significantly on your server infrastructure costs as well.

I've talked before about how you can accomplish some of this by eliminating most, if not all, of your client-side web scripting (such as Javascript) from your page. Doing something similar on the server side can reap similar rewards.

As an example:

Let’s say that you have a company website, currently utilizing PHP for page generation, along with a corporate blog powered by Wordpress. A straight forward, and incredibly common, setup. Tried and true.

At a very minimum you’re going to have, in addition to your web server, a PHP interpreter and a database (probably MySQL or something similar). Even with aggressive server-side caching, you’re still going to have a lot of overhead above and beyond simple html/file serving. That overhead manifests itself in slower page load time (every database connection, every PHP function that needs to be run, slows things down just a little bit more) and heavier server load (both in terms of memory and CPU usage).

Ask yourself: Does the front landing page of your website absolutely, 100%, need to be backed by a database? Is it necessary to load large sets of searchable, indexable data every time your homepage is requested? Is the layout and content of that webpage so dynamic and ever-changing that you need to have it backed by PHP, Ruby, or some form of pre-made content management system (like Wordpress)?

Odds are, the answer is a simple “no, not really.”

Now ask yourself a follow up question: Will my webpages load faster if they were simple HTML documents – as opposed to a large set of PHP files making multiple database connections to construct HTML files?

I can’t think of a single scenario where the static HTML file is going to be slower than the dynamically constructed one.

I hear your objections. You need a CMS to make your life easier, to make updating large numbers of pages a quicker process for you and your team.

Well, I’m here to tell you right now: That’s hogwash and poppycock. Most of you could save a huge amount of time, free up significant server resources (thus saving money), and make your websites load faster for your visitors… by using a simple static webpage generator system.

The idea is simple, and not entirely unlike using a CMS like Wordpress. You define a “theme” for the pages of your website to use. You then create and write the contents of each page – only, instead of putting that into a big database, you put each page in its own text file.

Then you run the static site generator. It creates the entire website (all of the pages) ready to go. And takes that load off of your servers… and speeds up page load times significantly. It’s not a terribly large change in the workflow of your web designers and developers… yet it can reap huge rewards in server performance.

In fact, the workflow can actually be improved as you will no longer need to maintain separate Test and Production databases. A simple source control system for your source files is all you’ll need to work on and test the latest revisions before going live.

Need to make a change (large or small) to every page within your website? Have thousands of pages? No problem at all. Tweak your theme, run the static page generator and the entire website is re-built. Often faster than a blink of an eye.

I, myself, am a fan of Hugo. A simple command line tool (that runs just about anywhere) that generates the pages for you. It even comes with a “mini webserver” that monitors for any changes you make to your themes or webpages… and lets you edit and test your site live. Extremely handy.

Jekyll is another popular option. I’ve only used it sparingly, but it works in a pretty similar way to Hugo and I’ve heard from many who swear by it.

Of course, both are Open Source (Hugo under the Apache license, Jekyll under MIT) so you can modify them to meet your specific needs.

If you’re still on the fence about utilizing a static page generator… let me leave you with this question: Do your visitors care what technology buzzwords you use on your server… or do they just want your webpages to load quickly?

Join the Network World communities on Facebook and LinkedIn to comment on topics that are top of mind.
Now read: Getting grounded in IoT