How to Optimize a wordpress Site
WordPress has a no. of components that should work together to provide a great user experience and optimizing those components ensure that your site performance is where it needs to needs to be for providing a pleasant experience to the users.
Below we will take a look on those components and how they can increase the performance of your WordPress site.
A non shared local disk will provide the most consistent and reliable performance.
Network storage plays its role. Always break up the problem you need to solve into components optimized for the need.
Never compromise on data redundancy even while using cloud based solutions
MySQL has developed into a scalable relational data store. You will want to ensure that the query cache is enabled and performing well for the website. That will ensure that MySQL is doing as little work as possible, freeing up resources for more essential thing than redundant queries.
You will also want to make sure that you use a tool like mysqutuner to ensure that your table performance is optimal. Switching engines to InnoDB having support for full text search is suggested for higher traffic sites. You won’t compromise the native WordPress search quality by making the switch. Percona distribution of MYSql is best if functionality like sharding, read replicas allow it to scale as your requirement grows.
Once you have ensured that MySQL your data store is not obstructive, then you need to analyze your queries generated by your theme and plugins to either optimize them, decrease their number through refactoring code or several caching techniques.
By default using transient in WordPress moves the problem of caching much like a time consuming API request and put it into the database. That may not be such a bad thing if that data was not serialized and stored in the same table as other settings in WordPress.
But now there are new options for reducing database load that will be highlighted shortly.
Use Relic stack traces to get an empirical view on where optimization can be done. Some of the rules to consider are
- The larger the memory usage the greater will be the execution time
- Take benefit of PHP 5’s auto load to decrease memory usage.
Make use of memorization and avoid loops where possible to decrease the execution time and memory usage. Avoid opening more files than in use so as to reduce calls to disk and memory usage. Use include and require rather than include_once and require_once.
APC is a free, open and robust framework for caching and optimizing PHP intermediate code. This means when added to your webserver you can realize dramatic speed improvements. APC keeps the interpreted version of your code in memory such the requests for it do not have to be re interpreted.
APC also provides an object store, allowing objects you create to be stored in memory right next door to the scripts that need them. The only disadvantage to this level of caching is that it is local to each respective application server that you have. This means the cache for object is rebuilt on each server and more importantly, purging of objects is tricky.
There are multiple copies of objects everywhere, with various states but there are solutions to the purging issue.
After optimizing the database and architecture it is time to fine tune your WordPress install.
Make sure that your WordPress plugins are upto date. Developers are always looking for ways to improve plugins and one of the way is to increase the performance of their code with each release. This is a very easy way to ensure that your plugins are always running at their peak performance. Unused plugins should be disabled so that they are not using valuable resources and load unnecessary code. It not only save space on your servers but also ensure that vulnerabilities are saved from developers that are slow to release patches or no longer support their plugin code.
Use WordPress Caching
The best WordPress caching tool is W3 Total Cached, but there are other tools that are also recommended by WordPress community like BatCache and WPSuper Cache. These plugin speed up your site and lead to large number of benefits for visitors and users who revisit your site.
Browser caching helps to reduce server load time by limiting the number of request per page. For example by setting the correct file headers on files that don’t change browser will then cache these files on the user’s computer. This technique will help the browser to check if file have changed instead of requesting them. The result is your web server can answer as many as 304 responses confirming that a file is unchanged, instead of 200 responses which require the file to be sent.
Content Delivery Network permits you to store images and large files on third party clustered servers across the world whose main task is to take content close to your website visitors thus making faster page download times.
Avoid using Google Sitemap Generator Plugin
This Google sitemap plugin reconstruct itself from scratch each time your sitemap undergoes any change, instead of adding changes as they occur. In spite of choosing another leading plugin from the WordPress repository that passes over this limitation. You should only download plugins from WordPress repository and not third party sites which may include phishing attempts or malware in the download.
For mobile Minification is important for improving end user experience. Limit the file size and number of files has a serious effect on the users experience with your site.
There are several tools for WordPress that assist the Minification process. When choosing one select the one that caches the minified files to disk, support local and remote files and the last it is compatible with content delivery network and mobile plugins.