Hyper fast wordpress

How to speedup wordpress without without changing your website.

Not one of my regular deeply technical posts but not any less valueable.

You’re probably here because you have a Wordpress based website and are not too impressed with the performance. There are a few approaches to make your content Hyper Fast ;-)

  1. use a cache plugin with minimal changes to the site
  2. use a cache plugin to build a static version of the site
  3. migrate content to a static site generator ( hugo / pelican / jekyll)
  4. cache your site in a cdn and purge when you update content

Today we are looking into the last one, cache everything at a cdn and purge on updates. Let’s go trough the steps:

Register at cloudflare.com

This is where your content will be cached.

Setup DNS and CDN

After you’ve created your account you need to start using cloudflare’s dns servers. This if done carefully, can be done without any downtime or hickups.

  1. Create the domain in your cloudflare account (this is in the sign up procedure if I recall correctly)
  2. Copy all the DNS records from your existing DNS provider to cloudflare trough their excelent web interface. Except the NS records, we’ll do these last.
  3. Make sure you have no orange clouds behind your records, we will enable their cdn later.
  4. You can make some dns requests with dig to compare old and new dns servers: (you can find your cloudflare dns servers in the web pannel)
domain="aapjeisbaas.nl"
# find your current nameservers:
dig +short ns $domain

# find your cloudflare nameservers:
dig +short ns $domain @ns.cloudflare.com.

# compare some records
dig +short a $domain 
dig +short a $domain @ns.cloudflare.com.

dig +short a www.$domain 
dig +short a www.$domain @ns.cloudflare.com.

dig +short mx $domain 
dig +short mx $domain @ns.cloudflare.com.

dig +short txt $domain 
dig +short txt $domain @ns.cloudflare.com.

If the results from your current and cloudflare’s dns servers match you can carry on to the next step.

Start using cloudflare’s nameservers

So your old and new DNS setup match, now we need to replace the NS records at your registrar. Most of the time the place where you bought your domain has a way to change your nameservers. Change them to the records provided by cloudflare, you can double check with:

# find your cloudflare nameservers:
dig +short ns $domain @ns.cloudflare.com.

To check if you changed your Nameservers correctly at your registrar use the following commands, keep in mind that this may take a few hours to be reflected in the results:

# output should contain cloudflare nameservers
whois $domain

# output should look like:
# aida.ns.cloudflare.com. dns.cloudflare.com. 2029044598 10000 2400 604800 3600
# \_ Your 1st nameserver   \_ contact          \_ serial  \     \    \      \_ ttl
#                                                          \     \    \_ expire
#  Changes in your dns wil increase the serial              \     \_ retry
#                                                            \_ refresh
dig +short soa $domain
dig +short soa $domain @1.1.1.1
dig +short soa $domain @8.8.8.8
dig +short soa $domain @4.2.2.2


# output should only contain your cloudflare nameservers
dig +short ns $domain
dig +short ns $domain @1.1.1.1
dig +short ns $domain @8.8.8.8
dig +short ns $domain @4.2.2.2

Test it

Try to send some mail cross domains, recieve some mail cross domains. visit your website from multiple machines and devices.

Enable cloudflare

To use cloudflare’s CDN goodness simply click on the cloud behind a DNS record in the dns admin interface. When it is orange with the arrow trough it, it is active.

Install 2 plugins to get the most out of this setup

To cache your pages at cloudflare for as long as you want: https://wordpress.org/plugins/cache-control/ Increase s-maxage to 604800 to cache for 1 week, you can leave the other options default.

To clear the cache when you update your site: https://wordpress.org/plugins/cloudflare/ After install connect it with your cloudflare account to allow your site to clear the cache. When your api connection is set up click the optimize for wordpress button to tweak some settings.

Take it up a notch

To cache all the pages you serve create a page rule for *testdomain.com/* with setting Cache level: Cache Everything

If you have any questions feel free to leave them below, if you want personal advice on how to optimize your specific website contact me

Cloud & Open-Source magician 🧙‍♂️

I try to find the KISS in complex systems and share it with the world.

comments powered by Disqus