The Quest for 0ms Page Load Times

If you are running a Wordpress or Drupal or other common CMS/Blogging platform based website, and you rely on an off the shelf plugin to provide fast load times for your website, you probably aren't getting the best performance you could.

Caching plugins can provide major speed boosts. Caching plugins can even make an unusably slow website quite enjoyable to navigate. Off the shelf caching plugins for Wordpress and Drupal offer a really good performance boost to effort ratio. (Eg. you get the most performance for the least work on your end). I see blogs and websites extolling the virtues of various plugins and other hacks and tricks.

Every time I open developer tools and refresh their pages, they sit in the two plus (2+) second range. These are supposed to be websites run by experts with the knowledge and authority to teach the methods of optimization, and yet I can't help but sit here and think to myself, “It's the year 2016, should your web page be loaded.. ya know before I navigate to it?” We have relative super computers in the palms of our hands and our butt pockets all day. We have blazing fast connections to severs on the other side of the world. We have blazing fast connections that can go through SPACE (like outer space.. you know, satellites?). We have walking, talking, and flying robots. Why should I wait two seconds for your page to load? I am already bored.


 

Page load time is affected by several factors, but in the continued spirit of over simplifying things for our own self gratification and entitlement fulfillment, lets assume they are as follows:

  • Network Connection

  • Processing Speed


 

Network Connection

The network connection here refers to the imaginary cloud that exists between your browser and a given web server. This cloud is full of wires, networking gear, maybe some radio waves and who knows what else.

You can upgrade your own internet connection to get some better performance, but you probably can't control your users' internet connection unless your are the Grand Emperor of the Universe. Since we really aren't self centered sociopaths and we really only care about the quality of our users' experience we will pretend that we are powerless to affect the client side internet connection and thus will be forced to endure whatever slowness it introduces.

 

Moving outward from the end users' home, we move into the more commonly known imaginary cloud called the “Internet”. Basically, we can't control this. The Internet is a big black box. We put data in one end and expect it to show up at the other. Governments and private ISPs control this leg of the journey so we will again have to live with the slowness introduced here.

 

As we finally reach your server we start to see somethings we can kind of control and some functions of our server that affect other layers. (We are talking in simple terms so our concepts will be a bit abstract).

 

First, if you hook your server up to a reliable Internet connection with plenty of bandwidth, every user that visits the site benefits. The return on investment can make a lot of sense here if you are starved for bandwidth on the server end.

 

Next, a thing called latency (the physical time it takes electrons or photons or whatever to travel from point a to point b), can be heavily affected by location. A user that is “next to” your server will have much faster load times than one much further away. But, this is tricky. We are not necessarily talking about geographical distance. Networks don't really believe in geographical closeness when they are routing data. Networks care about finding the fastest path. Sometimes that a user sitting in a building next to your server may have the traffic routed through another state / country before reaching the server.

 

It's some quirky stuff, but, if you are willing to pay, some really smart folks have figured out how to help alleviate the whole distance issue. These folks have set up Content Delivery Networks. These content delivery networks live in data centers all over. They will intercept a request for your website and through some networking wizardry, will route you to the “closest” copy of your site. That's how they operate. They take copies of your site and store them all over.

 

CDNs, so long as you are going with someone else's solution and not trying to build your own from scratch, can be quite affordable. They can provide great gains on page load speed performance, but I would tend to argue that those gains are largely do to the additional care that must be taken to caching in general in order for these services to operate. If your website cannot or is not cached properly, the CDNs will do nothing but add an extra hop and additional slowness to your site.

 

Outside of fancy networking caching, there is traditional client-side caching. This is where your server says to the user's browser, “Hey why do you just hold on to a copy of that file for awhile and if you want to look at it again, just ask me if it is still current or if I should send you a new one.” With proper client-side caching, once a user loads a resource on your site once, it is there. Instantly. We are talking 25 thousandths of a second to load the thing vs a 100 - 500ms round trip across the country.

 

Processing Speed

 

Do you use a CMS like Wordpress or Drupal? Do you have any ACTUAL live data? Here's the deal: PHP processing is expensive. The scientists and engineers have done some great things to make it really fast, but it takes time. You want the fastest possible page load time? Serve small .html files. Even running a PHP/python/node interpreter on your server will consume resources and limit the upper bounds of your performance.

 

The caching plugins that everyone seems so fond of are relatively simple (and complexly coded) mechanisms that cache the output from the backend interpreter. This is done in fancy ways so as to save you your sanity. You don't like being insane do you? The only problem with these plugins is that they tend to be software level as opposed to hardware or middleware. I won't get into hardware caching with in memory stores, but when I say middle ware, I mean your chosen server stack.

 

I rely on Nginx with PHP-FPM. I also rely on some meta scripts. You are on my website right now. I use a popular CMS. But you are not being served from my CMS. My entire website is cached as highly compressed html, css, and js files. PHP doesn't involve itself. I am not relying on any truly live data. I don't have to load stock tickers or anything else. The changes that are made to my website are things I do. Like publish an article. As such I am able to “pre-compute” my website.

 

I have an [unhealthy] obsession with fast page load times. My aim is to be faster than the Google home page. With that said I have taken somewhat “crazy” measures to ensure that you can truly see my content as instantly as possible. I am using strategies employed by the likes of Google and Facebook. They use the strategies just to keep their servers from melting. I use them on my zero traffic blog to shave off those last few milliseconds between you and my content.

Submitted by daniel on Wed, 04/06/2016 - 22:13