This article covers ways to improve speed of execution for WordPress but you could also look at it as a checklist to verify. Speed of a website is crucial to retain viewers. It is said that 47% of the viewers expect websites to load within 2 seconds, but don’t quote me from that this is just a figure from https://www.crazyegg.com/blog/speed-up-your-website/
Shared Managed Hosting
First question to ask is whether you are on shared hosting? If you are a shared hosting that means a few things. The machine on which you are running is shared with other users, just like the name suggests. So in case they exceed the normal X amounts of visits, for example 20,000 per month. And get a spike in traffic this could mean that your website experiences a slow down. This is because the resources are being used by the other user’s website. Of course this depends and might not happen.
Dedicated Managed Hosting
If you have the money available and you are experiencing significant traffic consider to invest in a dedicated hosting option. The other advantage is that this is also more secure. The other downside from shared hosting is that if a website from a user sharing the machine has been attacked by a malware. Then you could also be a victim of it. So the first advice if you can afford it is to buy the dedicated hosting solution.
Use A CDN
The next speed optimisation is to compress your images (and to serve them over a CDN actually). You can do the first part easily with a plugin. Many of them are available again well documented on WPBeginner https://www.wpbeginner.com/plugins/best-wordpress-image-compression-plugins-compared/
On top of compression you as far as possible you try to offload the images completely from your website. They easily the largest files that are going to be served by your pages. You can do this with the plugin: https://wordpress.org/plugins/amazon-s3-and-cloudfront/
Use PHP 7
If you are on Godaddy hosting for example you should make sure to check on your Godaddy dashboard that you are using the latest version of PHP7. PHP7 is nearly 2 times faster than Php5. However, before making any changes to the PHP5 please do it in a test environment/staging server first. It might be that not all your plugins have been coded to support PHP7.
Opcache uses a byte caching engine to save operations in memory. In short it will make your processing faster at the expense of memory. You should again conduct your tests in a staging environment. You need to make sure that you have the opcache extension and to enable it in your php.ini(opcache.enable=1) or your dashboard (if from a managed hosting). If you have access to the server then you are in luck, because although enabling is easier, tuning OpCache is much harder.
But there is a handy script available which does that https://gist.github.com/ck-on/4959032
Just like you offloaded images before you should also consider offloading memory. This can be done by installing a database like Redis and then using the following plugin https://wordpress.org/plugins/redis-cache/ to cache objects there. Careful to benchmark your system again or at least use monitoring to see if there is an actual improvement in performance from this.
This one is a free plugin you can download here https://wordpress.org/plugins/query-monitor/ which will basically allow you to find which queries are taking more time and also to allow you to check if there are any improvements from adjusting Opcache and object caching. Additionally, you could also pinpoint part of the code that is slow(and potentially identify plugins making your website slow).
If you have access to the installation of the MySQL server on which the WordPress site is running you could actually use the script here https://github.com/major/MySQLTuner-perl to get tips on how to adjust the configuration to get better performance.
A lot of people who run WordPress on AWS are unaware of the limitations present gp2 volume types. The IO limit is based on the size of the disk that you are using. You won’t feel this until you have expended your burst credit https://aws.amazon.com/blogs/database/understanding-burst-vs-baseline-performance-with-amazon-rds-and-gp2/ If you are experiencing a slow website you should consider monitoring that either with iostats command or cloud monitoring(if available). Same thing for other volumes outside AWS.
If you have access to apache2 then you should consider tuning this as well. You can use https://github.com/richardforth/apache2buddy apache2buddy which is the equivalent of MySQL tuner but for apache2. Things to take in consideration are the sessions sizes and how long they should last. It doesn’t make sense if you have a small blog to allocate too much to both of them. Anyway Apache2buddy will make a best guess for you.
If you have any other ways to optimise please feel to comment.
2 replies on “WordPress Speed Optimisation”
Hi, i read your blog occasionally and i own a similar one and i was just curious if you
get a lot of spam comments? If so how do you prevent it,
any plugin or anything you can recommend? I get so much lately it’s
driving me crazy so any help is very much appreciated.
Just lucky I guess