How I host reliable, secure, and performant WordPress sites

I host several WordPress sites. Notably, and this site. While I am no WordPress expert, I have developed a pretty refined skillset when it comes to web hosting and Linux over the years. I’d like to share some of my tips for hosting a WordPress site that is cost effective, scalable, and performant.

1. Avoid shared hosting

I would highly recommend avoiding shared hosting and using VPS or cloud hosting. This means that instead of running sites using a shared hosting provider, you run a web server on a Linux virtual machine that you rent. The reason I avoid shared hosting is that a site hosted on a shared hosting provider is sharing resources with every other site hosted on that server. This means your site does not receive much resources and is usually quite limited in what they allow you to do. Using a VPS provider (such as AWS, DigitalOcean, Hetzner, etc.) provides you with much more resources as your site is isolated from other users by the hypervisor.

Using VPS hosting allows you full control over your hosting environment and is usually cheaper.

If you don’t feel comfortable using Linux (although you should try and learn it as it is a great skill to have) you can opt to use companies like Cloudways that provide a control panel to manage your sites and run these sites on VPS servers, although you will pay more for this privilege.

2. Use caching

The first thing you should install on a WordPress site is a plugin like W3 Total Cache. This plugin uses a combination of your servers’ disk and an in-memory database like Redis to cache database requests and generated pages.

This means that your server doesn’t have to regenerate the HTML for a blog post each time it’s requested as this is a computationally intensive task. By utilizing caching, you can significantly reduce server load, load times, and increase the number of requests your server can handle.

All you need to do is install the plugin and install Redis. It can be set up in about 5 minutes and will improve your website’s performance substantially.

3. Use the right web server

Using Nginx + PHP-FPM is a much better choice these days than using Apache + mod_php.

Nginx is a much better web server than Apache and PHP-FPM is a much more efficient runtime for PHP than mod_php.

Nginx’s architecture is much better than Apache’s and enables it to handle more requests and respond faster. PHP-FPM allows your server to execute PHP faster while using less memory and taking better advantage of CPU resources due to its better use of multithreading and forking.

4. Use a CDN

Image showing a depiction of a CDN service
How a CDN works. Credit: Cloudflare

A CDN caches static resources on servers across the globe. This means, for example when a user requests a website hosted in Ireland from the United States, not every request must travel halfway across the globe, instead your CDN will serve static assets such as CSS, JavaScript, and images from CDN servers much closer to the user, usually in the same city.

They also help accelerate the connection to your origin server as they will use their massive backbone connection instead of public ISP routes. This will make your website much faster for your users, especially ones that live far away from your origin server. It also reduces load on your server and can reduce bandwidth costs as less request hit your origin.

CDNs can also protect your site from DDoS attacks and other common attacks. You’d be surprised how much of a difference a CDN can make.

I recommend and use Cloudflare as they have a fantastic free plan with unlimited traffic, provide best in class DDoS protection, are dead simple to use and have cache servers across the globe.

5. Cache content for a long time

By default, your server will only cache content in users’ browsers and on your CDN for a few hours. This means every few hours your CDN must check that the asset hasn’t changed. This is inefficient as most of the time an asset won’t change and if it does change it’ll normally be hosted on a different URL.

It makes more sense to allow your CDN to cache assets for much longer as this will improve performance and reduce requests to your origin. I cache CSS, JavaScript and images for a week.

To configure longer cache times for a WordPress site hosted on Nginx, copy and paste the snippet below into your Nginx site config inside the server block. You can increase or decrease this if you would like.

        location /wp-content/uploads {
                expires 1w;
        location ~ /*.(js|css)$ {
                expires 1w;

6. Use the right host

You should choose a host that will provide a fast server and network. If your host has a slow network, then your site will perform slow even if the hardware it’s running on isn’t overwhelmed.

I use AWS for a lot of sites as they are cheap and have a great network, but they are complicated, and they charge a lot for bandwidth and storage. DigitalOcean or Hetzner are also great choices that offer good pricing and are simple to use.

I host this site on Google Cloud Platform but only because they offer one free VM a month, forever. If you want to host your website for more or less free then check them out, otherwise I’d suggest one of the other platforms mentioned.

I hope these tips will help you host your WordPress website. For more content check out the rest of my blog.






Leave a Reply

Your email address will not be published. Required fields are marked *