Archive for the ‘wordpress’ Category

Wordpress Performance: Time Consuming MySQL Queries and Caching

Sunday, January 24th, 2010

I have been looking at a client’s Wordpress install the last few days. They have a large number of posts and page load times in general have been increasing. I installed some query logging based on the code in this article …
Rails-Like SQL Query Logging in Wordpress

Checking over the logs it became obvious that queries using SQL_CALC_FOUND_ROWS are a problem. Digging through code it appears that where a limit on results is used it uses this query modifier to allow simpler coding of paging. The problem is that since the main query to grab blog posts on the blog home page or any archive page uses this, on a large blog this becomes quite inefficient.

For now I have tweaked MySQL so that the MySQL Query Cache is now larger. These articles were useful:
MySQL Query Cache (at MySQL Performance Blog)
Turn on MySQL query cache to speed up query performance?

Looking at the log after this change query times have dropped dramatically (from over 0.5 seconds and up to milliseconds). This has immediately improved performance of the blog and overall load on the server.

I am currently looking at some WP Caching API and plugins to further improve performance.

If you are looking for some more ways to speed up Wordpress check out this article as a starting point:
4+1 Ways To Speed Up WordPress With Caching

And … for myself - just so I remember:
Install Memcache onto cPanel running CentOS

Setting up a scheduled event using the Wordpress “Cron” functionality

Thursday, May 7th, 2009

The function reference for wp_schedule_event provides code examples for creating a plugin using Wordpress’ “Cron” or scheduling functionality.

Hopefully this saves someone the few minutes it took for me to find this - pretty much everything you need to know!

Tip: Easy Export of Nucleus CMS Posts to import into Wordpress

Thursday, January 29th, 2009

I recently had to migrate blog posts in a Nucleus CMS-based blog to a Wordpress blog. Nothing against Nucleus which served a purpose for a long time and is still a really powerful piece of software. The migration is more to do with my experience working with Wordpres now than the quality of Nucleus. Anyway … I did a quick hunt for ways to migrate, which included some random code that referenced old versions of Nucleus and WP. I didn’t even bother with this. There is a much faster way.

The easy (and fast) solution proved to be modifying the Nucleus RSS feed so that it exports all the blog posts in full. These can then be imported into Wordpress.

Steps in brief (this might be different depending on your Nucleus version):

  1. Edit the skin for xmlrss2 in Nucleus. Find this (or similar) <%blog(xmlrss2,10)%> and change it to <%blog(xmlrss2,1000)%> where the second number is larger than the number of posts in your blog.
  2. Edit the template for xmlrss2 in Nucleus. It will probably look something like this:
    <item><title><%syndicate_title%></title>
     <link><%blogurl%>index.php?itemid=<%itemid%></link>
    <description><%syndicate_description%></description>
     <category><%category%></category>
     <pubDate><%date(rfc822)%></pubDate>
    </item>

    Change it to:

    <item>
     <title><%syndicate_title%></title>
     <link><%blogurl%>index.php?itemid=<%itemid%></link>
    <content:encoded><![CDATA[<%body%>
    ]]></content:encoded>
     <category><%category%></category>
     <pubDate><%date(rfc822)%></pubDate>
    </item>
  3. Open the Nucleus RSS feed in a browser (it should be really long and include the content of all your blog posts). Save the source (nucleusexport.xml for example).
  4. Reset the changes to the Nucleus templates and skins above so your feed is back to normal.
  5. Import the RSS feed into your Wordpress site (this used to be under the Manage tab, it is under Tools now).

Note: this won’t migrate comments and maybe other stuff that is important to you. This is purely the post content.

GZIP compression not supported by Wordpress 2.5+ (and what to do)

Tuesday, November 25th, 2008

I noticed that the GZIP compression option was no longer there in Wordpress after version 2.5. This is recommended to be performed by the server now using mod_deflate.

If you don’t have access to mod_deflate, i.e. if you are on a uncooperative shared host, you can use this method using .htaccess …
Speed Up Your Blog Using ZLIB

If that doesn’t work you may be on a phpSuExec server. Create a file called php.ini in the root of your Wordpress install with the following contents …

zlib.output_compression = On

You can test here:
http://www.gidnetwork.com/tools/gzip-test.php

Improving Wordpress Performance

Monday, September 15th, 2008

Looking at using Wordpress on a site that needs to handles many requests? This presentation discusses and refers to methods improve performance of your Wordpress-based site.

Modifying Wordpress Rewrite Rules - small problem + solution

Wednesday, September 3rd, 2008

add_filter('rewrite_rules_array','yourawesomefunction');

I had to look at the Wordpress core code to work this out - thought I was going nuts. If you apply new rewrite rules using the rewrite_rules_array filter you need to ensure that you refresh the rewrite rules that Wordpress has stored in a hidden option. You do this by simply resaving the Permalink Structure under the Options menu in the admin area of your WP install.

Not immediately obvious that this would be required, but makes sense that they generate the rules and store them at this point.

Free PHP Peelads - with plugin version for Wordpress

Wednesday, June 4th, 2008

I have seen Peelads running on a few sites. I like them as a non-obtrusive way to feature content or ads. I thought there must be some free code to run them. Sure enough, there is - Pageear.

What is even better is there are plugins for CMS software, including this Wordpress Pagepeel Plugin. Very easy to install and configure. Just upload a 100×100 image and a 500×500 image for the initial peel and the full display and set a URL.

Works well. Recommended.

bbPress is easy

Monday, April 21st, 2008

In the last month I have had to install two forums, SMF and bbPress, and deal with a forum install using phpBB. By far the easiest to install and configure is bbPress (from the same people as Wordpress). The others have pages of configuration options related to all tehir features. Frankly, unless your forum is targeting geeks or a bunch of people familiar with the overblown features of most forum software then go for bbPress. It also integrates easily with a Wordpress install. I had the forum up with template and functionality customized in a couple of hours. The plugin architecture allows adding features easily. Development seems to be a bit slower and quieter than most forums but this seems ideal for a simple forum.

Hint: if you want to use this for a private forum for your business check out these plugins …
Force Login to view the forum
Restrict Registration - only allow registration from people with an email address at particular domains (i.e. yourcompany.com)

Compiled list of the best Wordpress Plugins

Monday, March 24th, 2008

There are lots of lists of the best Wordpress Plugins. This article compiles the data from 48 lists - which mention 280 plugins in total - and creates a list of the top 30. A good place to start before installing something random.

read more | digg story

Wordpress plugin that adds an RSS footer to “foil scrapers”

Saturday, March 15th, 2008

Adds a footer to a blog post in an RSS feed that links back to the original blog post.

read more | digg story