10 Best Ways to Optimize WordPress
WordPress is a great tool, but its also a massive resource hog. I’ve used it for a while and decided that I’d put together my list of what I’ve done to speed it up and decrease resources, particularly RAM and CPU usage.
Check out the speed of your site first. This will give you a benchmark of what you have changed. If you have your own server then keep an eye on CPU and RAM usage. And to figure out what you need to konw about how good or bad your site is use YSlow from Yahoo for Firefox.
1. Use Amazon S3 to host all of your javascript, CSS, images and other multimedia. Offloading this to Amazon costs pennies and will substantially speed up your site, especially if you are hosting on goDaddy or some other shared server. I’ve been using an awesome Amazon S3 WordPress plugin and the S3 file organizer for Firefox to move files.
2. If you aren’t using Super Cache then install it now. That is the easiest way to save resources. Right now I’m testing W3 Total Cache. I’ve read lots of good things.
3. Permalinks can be a killer. My recommendation is to use this as your permalinks:
/%post_id%/%postname%.html
Why? Well the post id allows WordPress to quickly find the post within the database by id number. As your site grows wordpress has to search your database for matching post by name not a number like post id. Searching by name is not optimal.
4. Minimize the number of HTTP requests by merging all your JavaScript and all CSS files in one big file which really helps in lowering the HTTP request numbers. I had used WP-Minify, however that has caused me major log errors so try it at your own risk but there are other products like PHPspeedy (note I have not used this a lot but there are a lot of people endorsing it–do your research).
5. Optimize your database. And you can do that by using a tool like WP-DBManager. If you know how to get into PHPMyAdmin then go in and delete any tables that are left over from old plug-ins.
6. Remove site revisions. First you have to turn it off and second you have to clear them out of your database. You can turn off revisions by putting this into your wp-config file:
define(‘WP_POST_REVISIONS’, false);
Delete revisions in your database at your own risk!
7. Compress the content using apache .htaccess
If you have our own server you can chose to gzip all content sent to browsers. This will lower the loading time significantly as most html pages compress very well.
Add this code to your .htaccess
# MOD_DEFLATE COMPRESSION
SetOutputFilter DEFLATE
8. You will want to define the expiration of headers. This tells the browser how long it should keep the content in cache. Most of the images on your site never change and it is good idea to keep them cached locally.
Put this into your .htaccess:
# 1-WEEK EXPIRES HEADER
ExpiresActive On
ExpiresDefault A0
ExpiresDefault A604800
Header append Cache-Control “public”
9. Another .htaccess trick is to add this:
# KILL THEM ETAGS
FileETag none
This describes how ETags work.
10. One of the biggest problems with buying themes are the dozens of dynamic PHP and http calls. The fastest way to speed up WordPress is to replace the PHP queries with static HTML, every time a page loads, your browser just reads the HTML.
With PHP requests:
Without PHP requests:
You can remove 11 queries to the database by doing the following in your header.php and footer.php files:
- making your stylesheet URL’s static
- making your pingback URL static
- making your feed URLs static
- removing the blog’s WordPress version
- making your blog’s name and tagline / description static
for more examples go here for WordPress optimizing.
This isn’t a perfect list, but its some of the lowest hanging fruit.
Read More