Optimize WordPress: Advanced techniques

Optimize WordPress: Advanced Techniques

There are many things you can do to optimize your WordPress website. Here we go a bit deeper than basic WordPress optimizations to some more advanced techniques for how to optimize WordPress.

Note: Some of the following advanced WordPress optimization suggestions work better in certain server setups. Your performance may be different based on the server set-up of your hosting account.

Different Types of WordPress Optimizations

There are several types of WordPress optimizations:

Speed

SEO

Code

With WordPress, you can build just about anything. But that also means you must pay attention to the size of your site, the code of your site, the traffic you get on your site and make sure you are are optimizing your site to ensure you deliver the best experience for your users.

10 Tips on how to Optimize WordPress

1. Implement Caching

What is caching and why is it important to your WordPress site? By default, WordPress dynamically creates the pages and posts requested by your visitors from your database every time a visitor arrives at your site. For example, if you have 500 people visiting your site in 10-minute window (because you shared something on social media), your site will have to request 500+ separate PHP requests to build the front page for your visitors to view your site. This work can instead be handled by WordPress caching.

Once you implement proper WordPress caching, only the FIRST visitor will have to go through the PHP request process of pulling the data out of the database and rendering a page. Everyone else will be looking at the cached “already rendered” page.

2. Deal with Resource Hogs

Do you know which plugins on your sites use a ton of server resources? In order to learn more, you will probably need to install a WordPress performance plugin, such as P3 Plugin Performance.

But just to give you a heads up … here are some of the more popular WordPress plugins that use a large amount of resources in comparison to other plugins.

Disqus Comment System
Skype Status
Yet Another Related Post Plugin
Constant Contact WordPress Widget
NextGEN Gallery
Reveal IDs
VaultPress
wpCloaker
Digi Auto Links
PHP Code for Posts
Simple Post Thumbnails
WordPress Facebook

3. Stop Default wp-cron.php Behavior

By default, WordPress runs/executes the wp-cron.php file every single time a visitor arrives on your site. WordPress then runs off and tries to see if it needs to accomplish any tasks based on the last time it was run.

One way to optimize this area of WordPress is to disable the default wp-cron.php schedule and set your own.

This is an advanced WordPress optimization tweak.

First, add a line of code to the wp-config.php file:

define(‘DISABLE_WP_CRON’, ‘true’);

Then setup our own cron job (either through cPanel / server / or external cron websites like https://www.setcronjob.com ) to visit/run the wp-cron.php file every few hours rather than every moment someone visits the site.

You can also use a cron lock timer to only run a cron job:

define(‘WP_CRON_LOCK_TIMEOUT’, 900);

4. Turn Off or Adjust WordPress AutoSave

Turning off or adjusting the WordPress autosave interval from within the wp-config.php file can help save resource uses and help optimize your site.

define(‘AUTOSAVE_INTERVAL’, 300);

5. Log Out of WordPress When Not In Use

When you are logged into the admin area of a WordPress website, your browser can be sending multiple requests to the wp-admin/admin-ajax.php file that that can add up over time.

I’ve seen some servers that were seeing over 30 requests per minute for the logged in admin user which then resulted in the hosting account being temporarily suspended due to 300%+ CPU usage.

6. Deal with Search Engine Robots

Do you have a robots.txt file? Are you instructing the search engines on what they can and can’t do?

There are several things to things to think about when it comes to your robots.txt file:

User-agents can be defined
Files / Folders / Locations can be disallowed
Crawl-delay can help optimize your WordPress website

7. Block Users

Using a WordPress security plugin like iThemes Security Pro can handle blocking certain user agents or IP address, but you can also do it yourself with an .htaccess file edit.

The four main ways of blocking people from visiting your website:

Block by IP address
Block by User-Agent
Block by Referer
Temp Block Bots

8. Deal with Comment Spam

WordPress has the unfortunate ability to accumulate spam comments rapidly if you don’t do anything about it. Whether you set up who or how someone can comment on your website, or by implementing something like a WordPress reCaptcha on the comments box, something needs to be done to deal with comment spam.

Look at your SPAM IP logs … with a quick glance, you will see if there are some standard IP addresses that you could ban from your site.

If you simply want to eliminate spam opportunities but still allow those people to visit your site, you could add a little bit of code to the .htaccess file:

ErrorDocument 503 “Commenting disabled”
RewriteEngine On
RewriteCond %{REMOTE_ADDR} ^60.173 [OR] RewriteCond %{REMOTE_ADDR} ^218.10
RewriteCond %{REQUEST_URI} ^/wp-comments-post.php$
RewriteRule .* – [R=503,L]

9. Deal with Revisions

How many post revisions do you actually need? The problem with allowing post revisions to stay on your site does not rear its ugly head early in your site’s life … but, over time, the amount of revisions in your database will bloat your database. By placing a line of code in the wp-config.php file we can eliminate this issue before it becomes an issue.

define(‘WP_POST_REVISIONS’, 5);

10. Update All The Things

Make sure you are updating WordPress, your plugins, and your themes. Don’t leave anything out-of-date (i.e. vulnerable). Yes, there are security fixes and new features added with updates, but there are also optimizations of the code that many times are part of version updates.