How to Make Your WordPress Home Page Faster

by Jeremias Duarte. .

Posted in


WordPress is a great framework. It has loads of plugins available and everything is built under the GNU General Public License. However, many developers and webmasters may attest to the fact that most, if not all, of the themes and plugins developed for WordPress are not built with speed and efficiency in mind. Many themes and plugins are designed to be user-friendly, accomplishing some complex function without much knowledge of HTML or PHP programming.

However, for those of us with a great deal of knowledge of coding, there is one aspect of WordPress that renders it relatively inefficient – the database. Unfortunately, WordPress stores all information (even pages) as “posts” in a database. This makes for a relatively simple interface for editing, updating, and publishing new content to a website. However, this is at the cost of raw performance.

Most websites on the Internet, especially most of the clients that I have worked with, contain mostly static content and articles. These static websites require little, if any, functionality that is truly dynamic. The result is that every time a visitor accesses a web page, there are tons of unnecessary database queries and PHP processing done to render a small amount of HTML.

A client I worked with receives more traffic that most on the Internet, averaging roughly 100,000 unique visitors per day. The website was suffering performance issues, to say the least. After some extensive investigation, the bottleneck was indeed the database / MySQL / WordPress.

Beware: If you are not comfortable coding or using FTP, you shouldn’t follow this guide.

The Easy Solution

Removing the database altogether seemed to be the most effective solution, although not necessarily ideal for every situation. Since most of a website’s visitors view only the home page, removing the database remarkably reduced the server load. Doing so required a slight modification of a single PHP file along with the uploading of one more.

Step 1: Download the HTML Source of the Home Page

This step is fairly straight forward. Visit the URL of the homepage using your Internet browser. If you’re using Chrome or Firefox, simply right-click anywhere on the home page and click “View Page Source”. Highlight the HTML and copy and paste it into a text editor such as Notepad++. Save the file as a PHP file. Name the file anything other than standard file names such as “index” or “home”. Try using something like “optimized.php”.

Step 2: Edit the Website’s Index.php File

Next, connect to the website via FTP. If you download the root index.php file and open it is a text editor, you’ll find that it doesn’t do very much. All this file does is defined a constant that tells WordPress that a theme is defined, then it loads the WordPress blog header.

We’ll want to edit this file, essentially removing WordPress from the equation. In this method, I check the URL requested by the browser. If the URL is the homepage, I include a PHP file that contains the HTML. If the URL is not the homepage, just load WordPress and let WordPress handle the request.

Insert the following code just before the “define” statement in the index file.

if($_SERVER['REQUEST_URI'] == "/"){include_once 'optimized.php';}else{

Finally, insert a closing brace on the line after the require statement. Once you’ve edited the PHP code, you should be left with the following:

if($_SERVER['REQUEST_URI'] == "/"){

    include_once 'optimized.php';


     define('WP_USE_THEMES', true);
     require( dirname( __FILE__ ) . '/wp-blog-header.php' );


Step 3: Upload Both Files via FTP

Save the index.php file and the optimize.php file. Upload them both to the root of your website using FTP. That’s it!

Remember, the index.php file will be overwritten nearly every time WordPress is updated. So if you update WordPress, you’ll have to edit the index.php file again.