As your site gets traffic and clients or users, and as you start include extra content, then your WordPress website may start to slow down because of the fact that WordPress needs to recompile each page each time a client access to it. By using caching, you can decrease the measure of work WordPress needs to accomplish for each page load, which will then optimize WordPress website.
Since WordPress does not have built in caching functionality, one can utilize the W3 Total Cache module to add it to WordPress. To measure the improvement in speed, you can utilize the GTmetrix module. Let’s start with installing the GTmetrix plugin.
Installing the GTmetrix Plugin
Here, first install the GTmetrix plugin to help test the speed of the WordPress website. For doing this follow the below given steps:
- Log in to your WordPress as the Admin.
- From the left menu, hover over Plugins, and then click Add New.
- In the search box, type GTmetrix, and then click Search.
- Under the listing GTmetrix for WordPress, click Install Now.
- In the confirmation window, click OK to install the plugin.
- After the plugin has installed, click Activate Plugin.
- From the left menu, click GTmetrix.
- Open a new browser window, and navigate to this site http://gtmetrix.com/api/
- Click onGenerateAPI Key.
- If you already have a GTmetrix account, log in with your account. Otherwise, one can click on the Create an Account in the popup and enter your account details.
- After your account has been created, you may need to click Generate API Key again to generate the key.
- Copy the API key that you have generated, and switch back to the window with your WordPress administration page.
- If you are no longer on the GTmetrix configuration screen, from the left menu click GTmetrix.
- In the GTmetrix Account Email text box area, type the e-mail address associated with your GTmetrix account.
- In the API Key text box, paste the API Key you copied from the GTmetrix site.
- Then Click on Save Changes.
Running a Performance test using GTmetrix
GTmetrix helps one to determine the level optimization of your WordPress website. To run the performance test, read and follow the steps given below.
- Sign in to your WordPress as the administrator.
- From the left menu, hover over GTmetrix, and afterward click Tests.
- For testing your home page, click Test your Front Page Now.
- The test runs, and an evaluated score shows up.
- To see the nitty detailed results of the test, click Detailed report under the results of your test.
Installing and Configuring the W3 Total Cache Pugin
This W3 total cache adds functionality to the WordPress to optimize WordPress website. now for installing the plugins follow these steps.
- Sign in to your WordPress account as the administrator.
- From the left menu, drift over the Plugins, and after that click on the Add New.
- In the search box, type W3 Total Cache, and afterward click on Search.
- Under the listing W3 Total Cache, click on Install Now.
- In the confirmation window, click on OK to install this plugin.
- After this plugin is installed, click on Activate Plugin.
- From the left menu, hover over Performance, and after that click on the General Settings.
- On the off chance that the error message “The required directives for fancy permalinks couldn’t be detected” shows up, follow these steps given below:
- From the left menu, hover over the Settings, and after that click Permalinks.
- Select a method for Permalinks other than the default setting, and after that click on Save Changes.
- To come back to the W3 Total Cache Settings, hover over Performance in the left of the menu, and after that click General Settings.
- Under Page Cache, select the Enable check box.
- Under Minify, select the Enable check box.
- Under Database Cache, select the Enable check box.
- Under Object Cache, select the Enable check box.
- Under Browser Cache, select the Enable check box.
- And then click on the Save all settings.
- On the off chance if the error message “One or more plugins have been activated or deactivated, then please empty the page cache” shows up, chick empty the page
- Open the first page of the optimize WordPress website in a browser window, and refresh it a couple of times to confirm there are no errors. This permits the W3 Total Cache module to create the initial cache for your home page.
- As of now, you can run another test with GTmetrix to confirm the improved performance with the W3 Total Cache Plugin installed and enabled.
Adding Expires Directives to the .htaccess File
You should add Expires directives to the .htaccess file to completely permit browser-basedcaching. Expires headers instruct the browser to utilize a locally cachedcopy of a file as instead to downloading it from the server once more, as long as the local copy has been obtained within a particular period of time. You can also change the expiration dates of the things in these directives anyway you need.
For adding Expires directives to your .htaccess file, follow the given steps:
- Open the FTP connection of your WordPress website.
- Then download the .htaccess file and then open it in a text editor.
- Then paste the following directives at the beginning of the file, ensure that they appear before any other derivative in the file.
## EXPIRES CACHING ##
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 ##
- Save the .htaccess file, and then upload it to youroptimize WordPress website, as overwriting the existing .htaccess file.
- Then open your WordPress site’s home page and the verify the modified .htaccess file does not any kind of error.
- You can now also run another test with the GTmetrix to verify the improved performance with the Expires directives enabled.
Hope the information was helpful and you learn how to optimize your WordPress website with W3 total cache and GTmetrix with all the steps given above.