Up to 15x faster page load times with global CDN

Up to 15x faster page load times with global CDN

tl;dr: All Landen sites (free and paid) are now served from a global Content Delivery System instead of a server in a single US datacenter. This was always the case for static assets but now speeds up content as well.

There are lot's of factors impacting how fast a website loads in your browser - one of them being geography. Previously all Landen sites were delivered from a couple of servers in a datacenter in California. That meant fast load times for everyone close to that datacenter but the further you got away from it, the longer it would take for pages to load.

The chart above shows the load times for the index file (aka the content) of a typical Landen website (measured with Hyperpings free tool). As you can see it's pretty fast in San Francisco but much slower in Europe and Asia.

If you've ever left a website because it was annoyingly slow, you know how important fast load times are. Because Landen has customers all over the world it's important to make sure all of them can enjoy your websites. Site speed also plays an important role in SEO, with faster sites ranking higher in Google.

Serving sites from a CDN

I'll have to admit, I initially thought about developing and running the entire content network myself. Without doubt it would've been a fun and interesting adventure to set it all up, but maintaining a global server network at a company of one isn't really ideal.

I've been looking into lots of CDN providers for over a year, but it wasn't easy to find one. Most CDN providers specialize in hosting static assets and are only dabbling with website content itself. Then they are often geared towards just hosting a couple of websites and not thousands like Landen would need. Lastly, HTTPS is an absolute requirement for modern websites and yet some providers would charge extra for letting customers upload their own certificates.

Two providers finally came into close consideration: KeyCDN and Stackpath. I ultimately choose Stackpath because of their capabilities, pricing model, low cost of entry and really good support. Serving thousands of customer sites comes with huge responsibility so it's not easily shared with a third-party.

Setting everything up

Luckily I didn't have to make many changes to the site server itself to turn it into an origin for the CDN (an origin is where the CDN gets the content to serve to the user). For the most part I removed the caching mechanisms from the origin because all of that would be handled by the CDN now.

Next I had to setup all the sites in the CDN and make sure they stay up to date. An interesting challenge was to handle .landen.co subdomains differently than custom domains to reduce the number of total sites. If it wasn't for HTTPS certificates, it would've even been possible to serve all sites from a different CDN site and just cache content based on the Host header.

Result: super fast sites

Unfortunately there are still outliers and not every page load is below 100ms, however most load times have decreased from 2-15x:

Additionally blog content is now cached as well (it wasn't previously) and the main CSS file is served from the same domain. The CSS file is important for rendering the site in the browser and was previously served from cdn.landen.co regardless of your domain. This would require another DNS lookup.

There are lots of tools out there to test site performance, so feel free to test your own sites or www.landen.co with them to evaluate their performance. When testing, keep in mind that redirects are not cached and less visited sites might not be cached in some locations so run your tests a couple of times in a row to get an average.

Another benefit of moving all the content to a CDN network is the DDOS protection that comes with it. Most modern CDN providers offer DDOS protection out of the box, so that's one more thing my customers and I don't have to worry about anymore.

What's next?

Overall performance is very satisfactory now so I'll shift my focus back to improving other aspects of Landen and finally finishing up some pending features. However, I will get back to performance optimizations sooner or later and move more site assets onto this CDN and away from cdn.landen.co to reduce DNS lookups and improve load times even further.

One important piece of the puzzle remains unsolved for now and that is root domains. You can't point a root or "naked" domain such as landen.co to a global network directly because of technical limitations with DNS servers. That means that all requests to root domains (as opposed to subdomains such as www.landen.co) still go through Landen's server in California.

This is something I will certainly want to solve in the future and I'll provide another update then. Until then enjoy your super fast websites.

Like what you're reading?
Subscribe to be notified about future blog posts.

Made with