Tips on Optimising Wordpress for better performance (Apache and MySQL)

Below is a list of tips that I normally use as soon as I setup a Wordpress website. You are welcome to comment anything else that you do!

php7

Most of the themes and plugins are built for php5 so before switching to php7 be sure to check that your theme and plugins are compatible with php7. There are a lot of deprecated functions that have been removed from php7.

Other Performance Comparison: http://www.aerospike.com/blog/php7_php5/


Opcache

is a bytecode caching engine. It will execute php faster at the expense of memory.  Usually to configure it you need to make sure that you have the opcache extension and to enable it in your php.ini(opcache.enable=1) config. Installation is usually simple but tuning it properly is trickier.
In order to help you with installation you can use the following gist https://gist.github.com/ck-on/4959032/?ocp.php
For example if you run it and find the following you will know that all the opcache memory allocated is being used so you might consider increasing it:

Object Caching

Memcached or Redis can be used to make your website faster. You should probably only use one of them at a time. They are memory object caching system designed to speedup dynamic web application. In order to use it correctly make sure to install caching plugins which make use of them like WP Super Cache and https://wordpress.org/plugins/redis-cache/

Query Monitor

The query monitor is a plugin which you just have to install through your Wordpress admin dashboard. Then you have to set SAVEQUERIES to true in your wp-config.php
define( 'SAVEQUERIES', true );
Once you do this you will be able to monitor the loading times of the page, plugins, http requests, database queries and more! I personally see this plugin as crucial to optimising any Wordpress website. It's the perfect tool to detect slow plugins or even themes.


MySQL-Tuner

is a perl script that you can run on your server. It will ask you for the MySQL administrator username and password following which it will give you a report and suggestions to be added to your config file.  More information about the script here https://github.com/major/MySQLTuner-perl



apache2buddy

is the equivalent of MySql-Tuner but for Apache. You need to run it as root and the recommendations can look as follows:


More information here https://github.com/richardforth/apache2buddy

Cloudfare

Finally there is Cloudfare which offers auto-minification of css, javascript and html, caching of files and a bunch of other services. In order to use it, you will need to add their nameservers to your DNS configuration. The whole process is guided by an easy tutorial.


Final Words

We hope that this list was helpful to you. At the end of the day the way the theme and plugins were coded could be the most important determinant in your websites performance. Also there other ways of serving pages faster which I would encourage you to post in the comments with a link to the resource or even your blog :)

Comments

  1. Really nice (y)

    I am using all the methods mentioned and wanna add two more:

    1. Use a plugin which will optimize your css/js and also lazy loading etc. The best is WP Rocket(premium plugin)
    2. Installing Varnish cache which will cache your whole page for non logged in users.

    ReplyDelete

Post a Comment

Popular Posts