How to Optimize WordPress using W3 Total Cache and GTmetrix

As your site gains traffic and users, and as you add additional content, your site may begin to slow down because WordPress has to recompile every page every time a user accesses it. By utilizing caching, you can reduce the amount of work WordPress has to do for every page load, which in turn speeds up your site.

Because WordPress does not have built-in caching functionality, you can use the W3 Total Cache plugin to add it to WordPress. To quantify the improvement in speed, you can use the GTmetrix plugin.


INSTALLING THE GTMETRIX PLUGIN

First, install the GTmetrix plugin to help test the speed of the WordPress site. To do this, follow these steps:

  1. Log in to WordPress as the administrator.
  2. From the left menu, hover over Plugins, and then click Add New.
  3. In the search box, type GTmetrix, and then click Search.
  4. Under the listing GTmetrix for WordPress, click Install Now.
  5. In the confirmation window, click OK to install the plugin.
  6. After the plugin has installed, click Activate Plugin.
  7. From the left menu, click GTmetrix.

Note: At this point, you must obtain a GTmetrix API Key. The key is free, and allows you to run performance tests on your WordPress installation. Follow the procedure below to obtain an API Key.

 

  1. Open a new browser window, and navigate to http://gtmetrix.com/api/
  2. Click Generate API Key.
  3. If you already have a GTmetrix account, log in with your account. Otherwise, click Create an Account in the popup and enter your account details.
  4. After your account has been created, you may need to click Generate API Key again to generate the key.
  5. Copy the API key, and switch back to the window with your WordPress administration page.
  6. If you are no longer on the GTmetrix configuration screen, from the left menu click GTmetrix.
  7. In the GTmetrix Account Email text box, type the e-mail address associated with your GTmetrix account.
  8. In the API Key text box, paste the API Key you copied from the GTMetrix site.
  9. Click Save Changes.


RUNNING A PERFORMANCE TEST USING GTMETRIX

GTmetrix helps you determine the level of optimization in your WordPress site. To run a performance test, follow these steps:

  1. Log in to WordPress as the administrator.
  2. From the left menu, hover over GTmetrix, and then click Tests.
  3. To test your home page, click Test your Front Page Now.
  4. The test runs, and a graded score appears.
  5. To view the detailed results of the test, click Detailed report under the results of your test.


INSTALLING AND CONFIGURING THE W3 TOTAL CACHE PLUGIN

W3 Total Cache adds caching functionality to WordPress. To install the plugin, follow these steps:

  1. Log in to WordPress as the administrator.
  2. From the left menu, hover over Plugins, and then click Add New.
  3. In the search box, type W3 Total Cache, and then click Search.
  4. Under the listing W3 Total Cache, click Install Now.
  5. In the confirmation window, click OK to install the plugin.
  6. After the plugin is installed, click Activate Plugin.
  7. From the left menu, hover over Performance, and then click General Settings.
  8. If the error message “The required directives for fancy permalinks could not be detected”appears, follow these steps:
    • From the left menu, hover over Settings, and then click Permalinks.
    • Choose a method of Permalinks other than the default setting, and then click Save Changes.
    • To return to the W3 Total Cache Settings, hover over Performance in the left menu, and then click General Settings.
  1. Under Page Cache, select the Enable check box.
  2. Under Minify, select the Enable check box.
  3. Under Database Cache, select the Enable check box.
  4. Under Object Cache, select the Enable check box.
  5. Under Browser Cache, select the Enable check box.
  6. Click Save all settings.
  7. If the error message “One or more plugins have been activated or deactivated, please empty the page cache” appears, click empty the page cache.
  8. Open the front page of your WordPress site in a browser window, and refresh it a few times to verify there are no errors. This allows the W3 Total Cache plugin to generate the initial cache for your home page.
  9. At this time, you can run another test with GTmetrix to verify the improved performance with the W3 Total Cache Plugin installed and enabled. 


ADDING EXPIRES DIRECTIVES TO THE .HTACCESS FILE

You must add Expires directives to the .htaccess file to fully allow browser-based caching. Expires headers instruct the browser to use a locally-cached copy of a file instead of downloading it from the server again, as long as the local copy has been obtained within a specific perfiod of time. You can adjust the expiration dates of the items in these directives however you want.

To add Expires directives to your .htaccess file, follow these steps:

  1. Open an FTP connection to your WordPress site.
  2. Download the .htaccess file and open it in a text editor.
  3. Paste the follwing directives at the beginning of the file. Make sure they appear before any other directives:

  

                                    ## EXPIRES CACHING ##

ExpiresActive On

ExpiresByType image/jpg "access 1 year"

ExpiresByType image/jpeg "access 1 year"

ExpiresByType image/gif "access 1 year"

ExpiresByType image/png "access 1 year"

ExpiresByType application/pdf "access 1 month"

ExpiresByType application/x-shockwave-flash "access 1 month"

ExpiresByType image/x-icon "access 1 year"

ExpiresDefault "access 2 days"

                                  ## /EXPIRES CACHING ##

 

  1. Save the .htaccess file, and then upload it to your WordPress site, overwriting the existing .htaccess file.
  2. Open your WordPress home page and verify the modified .htaccess file does not cause any errors.
  3. You can now run another test with GTmetrix to verify the improved performance with Expires directives enabled.

 

  • WordPress, W3 Total Cache, GTmetrix, optimize wordpress
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Add MailChimp Subscribers from WordPress

You can add subscribers directly to a MailChimp mailing list from WordPress. This article...

Broken Image Links in WordPress

This articles describes how to resolve a problem that may occur when you try to add images to a...

How to Add CAPTCHA Protection to a WordPress Site

This article describes how to add CAPTCHA protection to a WordPress site using the Google CAPTCHA...

How to Add External RSS Feeds to your WordPress Site

This article demonstrates how to add an external RSS feed to a WordPress site. RSS (Rich Site...

How to Add a Custom Logo to WordPress

This article describes how to add a custom logo to a WordPress site. Adding a logo to your...

Powered by WHMCompleteSolution