WordPress Optimization For Speed Improvement

WordPress Optimization, we improve the site’s speed

I this post I will not refer to image optimization or moving scripts to footer, https or others. I will limit to a few simple things that can be done by anyone, observed at “volume” (the changes are minor as for speed gain is only about 0,.. seconds if you don’t have a big site, but as it grows you’ll earn more).

For example, the cron change below on a server with 32 sites has improved the loading speed of each site by over 3 seconds (well it’s more complicated each site had a bot posting in it at every 7 min or so and this is why cron became relevant). Trust me, eventually will gain some speed.

We optimize WordPress to reduce loading speed by deleting revisions

“By default” to say so, every time you make a change to a post (be it page, custom etc..) WordPress saves a “revision”, to help you bring the post to original form in the event of a mistake that you discover latter. Eh now you can save the original form in a file, make your changes and that’s it. The idea is that in a larger site these revisions accumulate and fill up database, increasing the response time in which your site is served to client. The solution is simple open wp-config.php
and add (above this comment /* That’s all, stop editing! Happy blogging. */):

The two lines do:
1.Autosave to 300 seconds
2.Disables Revisions.

Okay, now we’ve deactivated them so how do we clean existing ones?
We have several solutions, one of the command line (if you have ssh access to the server) and the second with a plugin. I prefer to do everything I can without the help of plugins because most of them slows the site(some simply by introducing additional information into the database)

1. Cleaning revisions and transients using wp-cli

I assume you have installed WP-CLI,if not here’s a tutorial: Install WP-CLi for better wordpress maintenance
Now go to site root (/var/www/site.com/public_html or whatever is your root)


(if you are logged in as root let the command with –allow-root if not, there is no need for it) more details about library here : https://github.com/trepmal/wp-revisions-cli

Notice –post_type=posts if you have custom post types, change to: –post_type=songs for example
If you have multisite, we can do a simple bash script for the above command:

Okay, now let’s get into transients.

optimizing wordpress by deleting transients
with this I deleted transientss. I recommend that you to make a CRONJOB for this (see below). There’s a bunch of useful stuff you can do with WP-CLI, look here: List of useful WP-CLI commands.

2. We clean up revisions and transients using a plugin

A plugin that I often use is WP Optimize if you are interested in what other plugins I use, see here Useful wordpress plugin list

We optimize loading speed by replacing default CRON

I found that the wordpress cron “sucks” to say so. Perhaps on a rare updated site there’s no difference, but if you have a bot to post in it things change. That’s why I prefer to disable the wordpress cron and replace it with a true cron :)

If you have multiple sites running on the same server and you want to use the server CRON for each of them, don’t start cron jobs at same time for each site, leave at least 10-15 min between crons.

In the wp-config.php put:

after that we have 2 options depending if you have ssh or cpanel

CRON from command line

Assuming you have the cron installed (if you do not see a tutorial Install crontab in centos for centos 6 and 7, ubuntu should have it already installed)

Now insert this:

so this cron will run every half an hour, and will have null output. If you want to see exactly what it is doing replce /dev/null with a file of choice. Remember to replace /var/www/site.net/public_html/wp-cron.php with the appropriate location.

We can add adtional crons:

to delete transitions and to optimize database.

WordPress cron from CPANEL

You log in, go to cronjobs, choose time (once every hour or less for a single site) and at command line write


Replace yourwebsite.com with your site.

Recommended: Cache plugins: WP Super Cache or W3 TOTAL CACHE

Now it depends on how you have the server. I usually install modpagespeed on the server with / or cloudflare and I don’t need any of these plugins, but when I can’t, I personally prefer to choose WP Super Cache more about plugins in WordPress category.

Options for WordPress Optimization

– Disable updates and transitions updates. See more Disable wordpress updates
– I’m trying to keep wp as clean as possible, I do not install plugins unless I absolutely need them, and I always look for the simplest (to do just the thing I need )

Examples wp-config.php and CRON on the command line:

wordpress config examples

Wordpress optimization Crons from command line
Last modified: February 11, 2018