How to optimize WordPress

DocumentationOptimisations > How to optimize WordPress

You don't want your users to be waiting for your website to be fully loaded longer that 3 seconds, it will result in a lower conversion rate and high bounce rate (the percentage your users leave after an number of seconds).

Thats why we want to lay out some methods for you to optimize your WordPress installation so you are sure you've did everything to make it run as fast as you can.

1. Choose quality hosting

There's a lot of hosting and cloud providers out there, especially with shared hosting you should be real careful. As a customer you cannot see how many users you are sharing the webhosting with, thats why we personally recommend to use your own server so you know you are the only one using it whilst at the same time having a unique IP address.

The providers you see on our partners page are quality hosting providers, with these guys you are assured to have decent hosting.

2. Use OPCache

OPCache is an amazing piece of software, what it basically does is cache PHP code in the FPM worker so it does not have to recompile each time a user loads your website. 

More on OPCache here

3. Install caching plugins

WordPress has a very easy and fast way to install plugins. With that theres a big plugin marketplace where you can get a lot of optimization plugins.

We've summed up a few caching plugins we recommend:

  1. WP Rocket - Caching plugin for WordPress (Paid)
  2. W3 Total Cache - Web Performance Optimization for WordPress (Free)
  3. Comet Cache (Free + paid)
  4. WP Super Cache (Free)

4. Optimize your images

Another thing is you might not even know is how big your images are, so optimizing them might be a good choice. There are actually a number of free tools that do this for you.

Also don't forget about the size and compression, these are important things that is forgotten a lot. For example, if you don't need transparency use .jpg format and nog .png, this reduces file size a lot.

5. Cache your assets (CSS, JS, images) in your webserver

If you are using NGINX as webserver you can add the following code inside your server {} block which is present inside your virtual host file:

# assets, media
location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
    expires 7d;
    access_log off;
}

# svg, fonts
location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
    add_header Access-Control-Allow-Origin "*";
    expires 7d;
    access_log off;
}

If you are using Apache2 you can use the following block to be added to your virtual host config file:

<ifmodule mod_expires.c="">
    ExpiresActive on

    ExpiresByType image/jpg "access plus 60 days"
    ExpiresByType image/png "access plus 60 days"
    ExpiresByType image/js "access plus 60 days"
    ExpiresByType image/jpeg "access plus 60 days"
    ExpiresByType text/css "access plus 1 days"
</ifmodule>

Make sure that when you added these changes you restart your webserver properly.

6. Choose plugins wisely

For each plugin that you add new code is added as well which has to compile, which results in more load time. Make sure that each plugin you install is absolutely required and being used. You'd be better off removing unused plugins than leaving them in there without it doing anything.

7. Tools

To know how your site is performing a number of tools might give you more insight about speeds and optimization.

01 September 2019
131 views