I’ve been having problems with my sites for a while now on various different VPS web hosting servers. Essentially, I’m getting intermittent faults, the worst kind and hardest to diagnose nevermind fix! Basically all my sites can be running fine then for no reason and without me making any changes to any site, they become incredibly slow. The server and/or apache dies more often than I’d like it too aswell, requiring a manual server restart.
I decided to do a bit of proper research and fault finding this week and while I can’t say for sure everything is fixed now, as of this moment, everything seems fine. Here’s a few of the things I done to try optimize a couple of my biggest, most trafficked sites – both WordPress blogs.
- Update WordPress itself to the most recent version,
- Update all plugins,
- Remove plugins that you don’t really need or which you can easily replicate the functions of by hardcoding, ie – Facebook Like Buttons,
- Limit plugins that communicate with external sources, ie – Facebook boxes, Twitter feeds, etc..,
- Only use plugins included in the WordPress.org database,
- Only use plugins that are listed as 100% compatible with your WordPress version,
- Keep images small and image numbers low,
- Use HTTP Compression,
- Use a Caching plugin like W3 or WP Super Cache,
- Database Queries tend to slow down a WordPress site so check your number by adding
"<!-- <?php echo get_num_queries(); ?> queries. <?php timer_stop(1); ?> seconds. -->"to your code and checking the page source on load,
- Debug your Queries by adding the Debug Queries plugin to see what the actual queries are and how long each one takes,
- Optimize your WordPress tables via phpMyadmin if you have access to it. The WP DB Manager plugin does this too if not,
- Delete database tables that have been left over by deactivated or deleted plugins. Be careful here!
- Turn off post revisions by adding “
define('WP_POST_REVISIONS', FALSE);"to your wp-config file,
- Delete all comments marked as spam via sql query –
DELETE FROM wp_comments WHERE comment_approved = 'spam';,
- Clean orphaned or unused entries in the WP-options table using the Clean Options plugin. Be careful!
- Raise the default WordPress memory limit of 32MB by adding
define('WP_MEMORY_LIMIT', '64M');to the wp-config file,
Finally, you can create a basic error log for your WordPress site by adding the following lines to the wp-config file:
Here’s a great article on WordPress Database Optimization.
One thought on “WordPress Optimization and Speed”
Another useful post Leon, I have had a nightmare with plugins, on our timeshare site, we have just stuck a basic template up while we write the content up, at some point we will try and add the blogging. We found that one way to find out if it is a plugin is to make a note of all the ones that are active, then disable all and see if problem goes away. Then reactivate say 5 at a time and retest each time, if it goes bad again, take those 5 and deactivate them, then reactivate one by one. The biggest problem we had was “content encoding” one of the plugins used something called ION and it was the culprit.