Tutorial Advanced WordPress Optimization Steps

Wordpress is a very flexible platform that allows for many plugins or customizations to be used so that every website is unique. However, these customizations can sometimes increase the time it takes for your website to load. In this guide, we will go through and share some of the more advanced steps you can take to optimize your WordPress installations.

Note: We recommend reviewing the Basic WordPress Optimization guide before reading this one to ensure that all basic optimization steps are understood.

The Advanced Steps:
These suggestions require a bit more knowledge of the file system of your WordPress installation as well as the database that it operates on. We recommend contacting a system administrator or WordPress developer for optimization assistance if you are not comfortable performing these steps on your own.

1) Enable Browser Caching

For most websites, the largest files on the website rarely get changed or updated. Normally this includes CSS files, Javascript, and your website images. Since the files do not change often, it may be best to take advantage of that and enable browser caching on your site.

Browser caching allows you to speed up the loading times for your visitors by storing a cached copy of these files locally. This can normally reduce the calls and time that your site takes to load when loading from a device as well as avoid the browser from needing to download the same images multiple times.

You can use the following code in your .htaccess file (/home/username/public_html/.htaccess is the path if WordPress is installed in the default document root) to enable browser caching for your website.

<IfModule mod_expires.c>
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 text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"

2) Optimize Your Images for the Web

While images can help improve the appearance of your page for visitors, they do use a large amount of storage. Because of this, pages that contain many images can take a long time to load.

It would normally be best to optimize the images for the internet before you upload them to your website. Most photo editing applications, such as Photoshop, can let you do this via a "Save for Web" option. When you save images with this option, the storage space used greatly depend on the size of the image. It is best to save the images closest to the size that you will be using on your page to save both bandwidth and storage.

A good plugin to optimize images that are already on the site is WP The plugin utilizes its API to perform a few tasks like optimize images, remove metadata from JPEGs, and convert GIFs into PNGs. Please keep in mind that while the script is running, it does take up a lot of resources and may temporarily impact your sites loading speed. Additionally, keep in mind that cPanel & WHM is not responsible for any issues resulting from the installation or use of third-party WordPress plugins.

3) Limit Crawlers and Bots from crawling your site

Often, your website will get crawled by different search engines and bots from around the world. Sometimes a bot may be crawling the site which can use a lot of bandwidth. This can start using too many resources for your website. To help avoid this, it is recommended to go through and set up a robots.txt file in the home directory of your website.

To block the most common search engines in the robots.txt, it will need entries similar to the following examples. These will go through and block the search engines from crawling the site completely:

User-agent: Yandex
Disallow: /
User-agent: Baiduspider
Disallow: /
User-agent: Googlebot
Disallow: /
User-agent: Slurp
Disallow: /
If you would like to go through and limit the search engines to specific folders you can go through and block specific directories:

User-agent: Googlebot
Disallow: /cgi-bin/
User-agent: Yandex
Disallow: /wp-admin
4) Limit Comment Spam

Spam comments can take up significant space in your database; this can cause requests to the database to take a longer amount of time as it has more information to go through. The easiest way to prevent these would be to install the Akismet plugin with your site so that it can catch and block any spam comments that may be made on the site.

Setting up Akismet is straightforward and in most cases easy to set up. To accomplish this, you would need to go through and set up an API key through their plugin which allows you to set up and put in an API key that you may already have. The next thing you’d want to do with Akismet is check the box in Akismet settings that says, “Auto-delete spam submitted on posts more than a month old.” Keep in mind that cPanel & WHM is not responsible for any issues resulting from the installation or use of third-party WordPress plugins.

5) Split Comments into Pages

Sometimes when you generate a popular blog or page, it can create a lot of comments. If you have a lot of comments on one page, this can result in a slow down of the page speed as it loads these entries from the database.

To help with this, you can split your comments into separate pages to reduce the page's loading time. This will allow your visitors to quickly load the page or choose to load up the comments separately.

To configure this setting, you will need to go to wp-admin's "Settings >> Discussion" page. Once there, go to "Other comment settings" and click on the option that starts with "Break comments into pages.." From there, you can set the number of comments you would like to display on each page as well as how the comments are ordered.

6) Limit post Revisions

It's not just trash that can needlessly increase the size of your databases. When you make a post and then edit it, the database saves the old and new versions to the database. Therefore, it is important to regularly delete spam comments and unwanted pingbacks.

In addition to one autosave of your posts and pages, revisions will be generated each time you save your articles. This means that an article can take up to ten times more room if there are ten revisions then the actual article that was published.

By default, WordPress will save an unlimited number of revisions. However, this is normally not needed. It would be better to reduce the number of saved revisions to normally two or three. You can do this by adding the following code to your site's wp-config.php file:

 define( 'WP_POST_REVISIONS', 3 );
You can also completely disable the post revision system through the wp-config.php as well by adding the code snippet below:

 define( 'WP_POST_REVISIONS', false );
7) Disable Hotlinking and Leaching of your Content

Many users encounter situations where remote domains are loading resources from their website. This behavior is not only stealing images from your page but can also increase the bandwidth usage of your server as well.

To go through and block hotlinking to your site, you can add the following code snippet to your .htaccess file:

#disable hotlinking of images with forbidden or custom image option
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain.tld [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain-2.tld [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ – [NC,F,L]
Note: Don't forget to change domain.tld with the domain your website is being created on.

8) Use a CDN

Another popular option to help with your sites is to go through and set up your website with a Content Delivery Network (or CDN for short). Your site is in a datacenter somewhere in the world if you are going through with a hosting provider. However, the further away from the datacenter that you are the longer that it will take to load because the distance is greater.

A CDN can address the issues in regards to the visitors being far away from the datacenter that the site is however by using its network of Datacenters around the world to help push your content out. Most CDNs will only do the static parts of your site such as images, CSS, and other parts of your site that may not change much, however, this will help save your bandwidth and have the server work less to respond to replies for images if a CDN is in the middle.

The most popular CDNs out there are CloudFlare and MaxCDN. CloudFlare does have a free tier of service that you can do though some services and options are locked. For MaxCDN they do have a $10/mo package that also gives you the first month free.

Additional Information
In some cases, the server load may be higher than normal and may not be tied directly to the WordPress installation. In those cases, we would highly recommend checking out our guide on troubleshooting high server loads.

Additional Questions/Feedback
Feel free to click on the Discussion tab to let us know if you have any questions or feedback about the information in this tutorial.
First release
Last update
0.00 star(s) 0 ratings