This tutorial will show how to reduce the CPU load on WordPress site. The fact is that you will never want a slow server which might affect your Google page ranking, a constant server crash or your web hosting company shutting off your site without warning due to excessive usage of CPU resources.
Here I will show you some of the important methods to optimize your WordPress site.
Enabling caching for your website can boost its speed significantly because caching ensures a much faster experience for your website users by storing a version of your website on their browser and serving them that version until your website is updated or until you instruct it to refresh the version of your website they are served.
When you use CMS like WordPress then the higher version of WordPress comes with a feature known as Object Cache but it is by default not enabled, so you can enable it by following way
Step 1. Login to your hosting server cPanel
Step 2. Go to the root directory of your WordPress application
Step 3. Edit the wp-config.php file
Step 4. Update or insert the following line in the above file
Step 5. When you enable the cache, then cached files must be kept somewhere in the sever, so create the following directory
Step 6. Change the permission of “cache” folder as 755 or 777 so that the caching would be writable into this folder
If you want you can also set expiration time to WordPress Object Cache by inserting the following line in the wp-config.php file
Note : If you do not want to use WordPress Object Cache then you can use any one of the following good caching plugins
Choose good WordPress theme
Choose simple WordPress theme for your blog site, because your theme is the face of your site and plays an important role in how users and search engines perceive it.
Many WordPress themes come with lots of customization options. If the theme is not coded properly, these options can make it difficult for you to modify themes. Therefore either you will be locked into that theme or need to pay a developer to help you switch.
On the other hand, some WordPress themes which look really great actually make your website incredibly slow. And no one likes slow websites, particularly Google, which prefers to rank faster websites higher.
A well coded theme will greatly reduce the number of queries, have minimal W3C error and is Google friendly.
The the theme should be Responsive because these themes adjust their layout across different screen sizes and devices. A significant number of site’s traffic is generated from mobile, tablets and other handheld devices. Depending on your website’s topics, this number could go even higher than 50% of your traffic.
Lazy Load Images
Lazy load images to improve page load times and server bandwidth. Images are loaded only when visible to the user. You can use WordPress Lazy Load plugin that is very useful with lots of images.
Enable GZip Compression
Gzip is, also a file format, a method of compressing files to make them in smaller size for faster network transfers.
Compression allows your web server to provide smaller file sizes which load faster for your website users.
Enabling gzip compression is a standard practice. If you are not using it for some reason, your webpages are likely slower than your competitors.
The following URLs may be useful for testing whether your site has GZip Compression enabled or not
Clean WordPress wp_options table
When you install and activate a new plugin, it stores plugin configurations in the MySQL ‘wp_options’ table. It may be a good idea to clean the WordPress wp_options table. You can do cleanup manually by logging to the cPanel, there should be a tool there called PHPMyAdmin. Using PHPMyAdmin, you can directly view and manage all your MySQL databases.
Remember to backup of your database & deactivate and delete unused plugins before performing the cleaning up process.
You can use the WP-Sweep plugin for this purpose. WP-Sweep allows you to clean up unused, orphaned and duplicated data in your WordPress to optimize your database tables.
There are two old plugins which may be useful for cleaning up the database
Use a Content Delivery Network (CDN)
If you website is hosted on servers in the US then the website will generally be fatser for people living in the US or people visiting with a US VPN but your website will be slower for people from other parts of the world. It is also true if your website is hosted on servers in India then people visiting your website from India will be faster and people from rest of the world will be slower.
Therefore CDN comes to rescue by distributing your website files across a network of servers in different locations of the world so that someone trying to visit from other part of the world where your website is not hosted will see significant increase in your website speed. For this you do not need any plugin or special software. You do not even have to spend much on another web hosting plan – simply upload the images to a CDN.
Here are some CDN options:
Optimize your images by reducing size because un-optimized images consume a lot of server resources and take a longer time to load due to heavy size of the images. If the average size of the images is more than 1MB then you have got to do serious work on it. You can significantly reduce the size of your image to reduce the server’s load and web hosting bandwidth while ensuring that its quality is not negatively impacted by using any of the following tools:
You can use any one of the following tools to compress your CSS files
Minimize the Number of Plugins
Keep plugins which are required only. We know that plugins help enhance your website’s functionality and look & feel but it is also important to only use a plugin if you feel that it is absolutely necessary. Because, unnecessary plugins can reduce your website speed significantly and it is especially important to pay attention to them if you are using blogging CMSs like WordPress or Joomla.
It is very important to keep in mind that it is not always the number of plugins you have installed but also about the quality of the installed plugins. Sometimes a website installed with 20 plugins may be faster than a website installed with 5 plugins due to the poor quality of the 5 plugins installed in the website. The poor quality plugin, that performs a lot of extra database queries and remote requests, should always be avoided.
Enable HTTP Keep-Alive
When visitors browse pages in a website then many files are requested by the browser from web server for a page to be displayed on the browser. So each time http connection is opened and closed for a file that is loaded from the web server. This uses more CPU, network & memory and eventually leads to a slower website if there is a lot of load on your server. Enabling http keep-alive ensures that all files are loaded through a single opened connection from the server which leads to a more faster website while visitors are browsing the website. It also reduces the extra burden on the web server.
The http keep-alive can be done through htaccess
Header set Connection keep-alive
Prevent Others from Hotlinking Your Images
Hotlinking refers to linking directly to non-html objects on other servers, such as images, movie, css, zip, pdf files etc. This can greatly impact bandwidth usage because when people hotlink your images, they are basically stealing your bandwidth since a request will be made to your server every time their readers tries to view the images on their website. Hotlink protection can save you lots of bandwidth by preventing other sites from displaying your non-html.
You can check how to do it here
Test the speed of the WordPress site
After optimizing your website it is important to test whether your website speed got optimized or not. There are online applications available that do this for free including favorite Google PageSpeed Insight.
Thanks for reading.