How to Improve WordPress Performance Top Ten Tips - Part 1 of 2

How to Improve WordPress Performance Top Ten Tips – Part 1 of 2

The fastest kind of website is one with static content, without images and saved to a single file, like an HTML page.
However, this solution is not scalable since it is not easy to change content over time nor is it visibly appealing, since everyone loves to look at pictures not just text.

Improve WordPress Performance
Photo by: bobbigmac

Therefore, websites have changed over the years to be setup so that the content can be changed easily, provide nice user interfaces and have images to make the content easy to understand. This was achieved by introducing Content Management

Systems (CMS) such as WordPress. According to Forbes.com, WordPress is the platform being used on one out of every six websites on the internet. This is nearly 60 million websites running WordPress with 100,000 new sites each day.

According to WordPress.com, 380 million people view more than 13.3 billion pages each month. Also, users produce about 35.4 million new posts and 61.2 million new comments each month.

Since there are so many WordPress sites being used today, it means there are a number of tools at your disposal to keep your website running fast and improve WordPress performance.

WordPress Structure

WordPress is made up of two parts, the database and the website files. Either one or both can have a negative impact on your website’s performance and page-speed. It is important to address both parts, not just one of them.

WordPress Database

MySQL Database
By: Kevin Severud

Since WordPress is a CMS, it was designed for database-driven content. This enables the author of a website to easily update the content and make it visible to their readers immediately. WordPress was developed to work on MySQL, which is an open-source database currently owned by Oracle, but there is only free, community-based support for it available.

This means that the website operator is responsible to provide tools to backup, restore, and optimize their database. However, due to the popularity of WordPress there are some great plugins available to help with this.

If you are self hosting your own WordPress site and have full access to the MySQL database, there are many websites with tips, tricks and scripts you can setup and/or schedule to run on a regular basis to optimize your database.

However, if you are like most small businesses or personal websites, you will host your website on a shared hosting environment, like Webnames.ca Hosting offers. If you are using a shared hosting environment, you will most likely have limited access to the database, through the hosting panel to the standard phpMyAdmin interface. To make life easier,  and save a lot of time and effort, I strongly recommend you skip this complex user interface and  install the WordPress plugin, “WP-DBManager”.

WP-DBManager Plugin for WordPress Database Maintenance

WP-DBManager Sidebar MenuThe WP-DBManager offers a great-looking sidebar menu that  provides your website adminstrator with many key tasks that need to be performed on your website to optimize your MySQL database.

The first menu item, Database, will show you all the tables in your database and the sizes of each table. If you are concerned about the size of your database, this panel will show you the total size of the data and indexes on your site as well as the number of database records.

The Backup DB menu item allows you to do a one-time backup and compress the backup result as a GZIP file.

The Manage Backup DB menu item allows you to email a recent backup to a specific email address, restore this backup, download this backup or delete it.

The Optimize DB menu item sets up a database optimization to occur per table (so you can turn it off for some tables if you want). This is not where you schedule the optimization, just choose the tables impacted by it.

The Repair DB menu item will let you repair all or some of the key WordPress tables should they get corrupted and break. This can be used instead of the built in WordPress repair tool which does not allow you to choose the tables to fix.

The Empty/Drop Tables menu item allows you to delete or empty tables in your WordPress. Never ever, use this feature as it will break your WordPress site and require you to restore it completely from the most recent backup. I wish it was an option to disable this from appearing in the plugin.

The Run SQL Query menu item allows you to run, insert, update, delete, create and alter statements. This is a great tool if you need to view some posts in your database and  need a quick tool to find them. This is more a developer tool, than an everyday user tool.

Finally, DB Options menu item allows you to setup the paths for your backups. For mysqldump path, normally it is ‘mysqldump‘. For mysql path, normally it is ‘mysql‘. Make sure you set a maximum number of backups to keep online at one time as it takes away from your website storage limits.

Please note, when you install the WP-DB Manager plug in, you will get the following error “Your backup folder MIGHT be visible to the public. To correct this issue, move the .htaccess file from wp-content/plugins/wp-dbmanager to /var/www/vhosts/…”

WP-DBManager error move the .htaccess file from wp-content/plugins/wp-dbmanagerIn order to fix this error, you need to move the  “htaccess.txt” file from wp-content/plugins/wp-dbmanager to the location specified in the message and rename the file to “.htaccess”. Once you do this and refresh your dashboard, the error will disappear.

Clean Up your MySQL database to Save Space

Remember that ALL your website content, including text and images, is being stored in your MySQL database. This means that if you upload 100,000 images (duplicate or not) and are only using the most recent three, your database still has to keep all 100,000 available. This takes up a lot of storage and can make your backups huge.

Remember to overwrite your backups  after a certain number, or they will keep growing and use up your available storage.

WP-Optimize Plugin for WordPress Database Optimization

WP-Optimize WordPress Optimization Plugin Although the WP-DBManager has an option to optimize the database, this will only optimize the MySQL physical tables to perform at their best using the built-in optimize table command in MySQL on a regular interval. However, there is another type of optimization that can be done to help keep your WordPress database small and fast. WP-Optimize is a WordPress plugin that will remove your post revisions, auto drafts, spam comments and unapproved comments. Also, you have the option to run a database optimization immediately, rather than wait until it is scheduled to run.

WP-Optimize WordPress Plugin Options

Remove all Post revisions – Whenever you save a post, the WordPress site will keep a copy of the old post so that if you make a mistake, you can reverse it. If you change a post and save it 10 times , you will have 10 copies of the same post stored in your database. This post revision process is a great backup tool, but if you have most of your articles published, you don’t need historical copies of them (on top of database copies done when you backup your site). This feature will purge all the post revisions in your database and I recommend you run this once in a while (the frequency depends on how often you change content on your site).

Remove all auto draft posts – In WordPress 3.6, there is a new auto-save feature so users never lose posts due to expired cookies, lost internet connections  or an accidentally-closed  browser. WordPress will now auto-save your work while you are writing after a certain period of time. However, over time, the saved drafts of your blog posts will increase the size of your database. I recommend you run this at regular intervals to keep your database small.

Clean marked Spam comments – After the Webnames.ca Blog was migrated to WordPress from Movable Type and launched, within 10 minutes, I had 26 spam comments submitted via bots. I installed Akismet the anti-spam comment plugin and it has marked a log of comments as spam and put them in the spam comment folder. This option will let you delete all spam comments with one click from your database.
Clean Unapproved comments – If you have unapproved comments and you know they are all spam as well, you can delete them all with one click.

Optimize database tables – Although the WP-DBManager will schedule the MySQL database optimization task, you can manually run it once via this option.

I ran this plugin once after our blog had been running for a month and it shrunk our database by 25% immediately.

Revision Plugin for WordPress to Limit your Post Revision Count

Instead of deleting all your post revisions via the WP-Optimize control, you can control the number of revisions you keep in your database instead. If you make frequent changes to a post or have multiple authors of a post, you can easily get 100 revisions. Instead, install the Revision Control plugin and you can set the number of post revisions to keep. If you set the value to three, only the three most recent versions of your blog post will be kept in case you make a mistake. This enables you to keep some revisions of the posts without filling up the database with tons of unnecessary revisions.

WordPress Hosting Platform

WordPress can be hosted on any platform that supports PHP. If you are looking to have your website hosted somewhere as you don’t want to host it yourself locally, I recommend that you get a good stable hosting provider such as Webnames.ca. Some hosting providers overload their servers on purpose with the hope that some sites will not get much traffic to make up the difference. However, Webnames.ca does not do this. If you want more information about hosting options, view the Webnames.ca Hosting Features page or contact a support staff member and they can help you with any addition questions you might have.

WordPress Website, Theme, Plugins, Widgets and Files

The most important component of the standard WordPress website to performance tune is the actual website itself (excluding the core WordPress libraries that make the CMS run).. These are the features that a website creator has full control over and can help or hinder the performance of a standard WordPress website. I will be discussing these optimizations in my next blog post How to Improve WordPress Performance Top Ten Tips – Part 2 of 2.

 

Posted in:

Developer's Corner Technology and Social Media
/* Adroll script */