Surf Roots, Software Thoughts

A blog by Alex Loddengaard

Archive for the 'WordPress' Category

The Effectiveness of WordPress Caching with WP-Cache

I got curious and started load testing my blog using the Apache ab load testing tool.  I didn’t have any caching setup when I first ran ab.

$ab -kc 10 -t 10 http://www.alexloddengaard.com/

Requests per second:    8.19 [#/sec] (mean)

During the ab run my server’s CPU usage was at about 99%.  That’s insanely awful considering my web server is monsterious, at least to my standards.  I installed the WP-Cache WordPress caching plugin to see how that would improve things.  Take a look:

$ab -kc 10 -t 10 http://www.alexloddengaard.com/

Requests per second:    44.60 [#/sec] (mean)

The CPU usage during this ab run was about 3%; much better :).  I was curious to see how many requests per second my machine could handle ignoring network latency, so I ran ab from my server on itself and got a much more impressive result:

$ab -kc 100 -t 30 http://www.alexloddengaard.com/

Requests per second:    1140.20 [#/sec] (mean)

Lesson learned: WP-Cache is a must-install WordPress plugin.

1 comment

Better Code Syntax Highlighting in WordPress

I’ve written previously about syntax highlighting in WordPress, but I’ve found a better plugin since then. Google’s syntax highlighting plugin for WordPress is much better; and thank god it supports Delphi.

Here’s an example:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

Pretty shnazzy, huh? Here are the usage instructions and language support.

I had to make one minor change to one of their CSS files. I changed Styles/SyntaxHighlighter.css such that the .dp-highlighter .bar definition had a smaller left padding. Take a look:

.dp-highlighter .bar {
    padding-left: 30px;
}

Enjoy!

No comments

The Power of Trackbacks

After not having checked my Google Analytics for a while, and after getting very tired of my statistics homework, I decided to take a peek and see how my blog traffic was doing.  I wrote a post a few days back about my second impression of Ruby on Rails; in that post I linked to a TechCrunch post that, at that time, had been recently published.  It turns out that the TechCrunch article that I linked to turned out to be a hot post, and my trackback turned out to be the first of many.  TechCrunch referred 10x the amount of people that normally visit my blog, and the referrals are still coming in.

The moral of the story is that trackbacks may not help SEO at all, but it’s definitely a good way of getting referrals.  I just wish my post was slightly more interesting.  Maybe then my subscriber count would have increased more (it didn’t really increase much at all).

1 comment

Google Reader Shared Items On Your Blog

You may have have noticed that my sidebar now has a section for items that I’ve recently shared in Google Reader.  I did this using the following two WordPress plugins:

Once you’ve downloaded these plugins to the /wp-content/plugins directory, follow these steps:

  1. Unzip and Activate these plugins
  2. Create a writable cache folder in /wp-content/cache (this problem is solved if you use WP-Cache)
  3. Login to Google Reader
  4. Click “Your Shared Items”
  5. Read through the text on the right side of the screen and look for a “a feed” link that is a link to your recently shared items in Reader
  6. Follow the SimplePie WordPress Plugin usage instructions to learn what PHP code you’re interested in.  It’ll look something like echo SimplePieWP(”your_feed_url”);
  7. Create a new template to customize the look of the feed.  This is the template that I’m using:

sh: /usr/bin/states: No such file or directory

I hope this helps!  Shoot me a comment if you run into any problems.

No comments

Changing the Allowed HTML Tags in WordPress

I’ve been trying to get certain HTML tags to not be filtered by WordPress, and I found a good article that explains how here.

No comments

Blogging Analytics

Two absolutely must-have blogging analytics are Google Analytics and FeedBurner. FeedBurner lets you know how many RSS subscribers you have, and Google Analytics gives you a bunch of awesome stats about your website in general. For example, you can know the keywords by which readers reached you via organic search, the amount of time readers spend on your site, unique visitor counts, hit counts, etc. Google Analytics is super easy to install, so there’s really no reason not to have it.

FeedBurner is also super easy to setup, but there are a few use cases that require some technical fiddling:

What if you need to change your feed URL in the future and you’re using FeedBurner’s URL?
When you sign up with FeedBurner, they’ll give you a feed of the form feeds.feedburner.com/some_feed_name. If you link your users to this feed, then you’ve lost all control over the whereabouts of your feed. Users will start adding that feed to their readers, and you won’t be able to redirect them if necessary. FeedBurner offers a service called MyBrand that allows you to create your own host (e.g. feeds.example.com) with a CNAME record such that users will subscribe to feeds.example.com/some_feed_name and will actually be reading from feeds.feedburner.com/some_feed_name. This means that you have control over the whereabouts of your feed. FeedBurner has a very nice tutorial on how to set this up.

If you already have a bunch of subscribers, then how will they be redirected to a FeedBurner feed?
You can make an Apache Rewrite rule that forwards your old feed URL (probably example.com/feed) to the new FeedBurner URL unless the user agent is FeedBurner. Take a look at this post for more info.

Here’s a little diagram I whipped up to describe what happens when you’re running MyBrand and Apache rewrites:

feedburner.png

Again, Google Analytics is cake to setup.  FeedBurner by itself is also cake, but the two cases mentioned above do require some fiddling.  Go install both of these if you haven’t already!

2 comments

Beautify Your Permalinks in WordPress

WordPress allows posts to have pretty permalinks, but they don’t work right out of the box. Permalinks of this form perform much better in search engines. I had to fiddle with some Unix permissions and some Apache configs to get them working correctly, so I thought I’d share my experience. While working through this, I commonly got 404 and 403 errors when accessing my blog, so be careful when applying these settings.

Step 1: Apache
Apache needs to be configured correctly. The following code needs to either be put in your virtual host file or in the main Apache config file (apache2.conf in Ubuntu and httpd.conf in others).

sh: /usr/bin/states: No such file or directory

Step 2: Unix Permissions
Eventually you’re going to have to change some options in the WordPress admin panel, but some permissions need to be setup first. When you change your permalink structure, WordPress is going to write to .htaccess in your WordPress installation directory. This means that this file needs to be world writable before WordPress tries to write it. Run the following commands in a shell to make sure .htaccess has the right permissions:

sh: /usr/bin/states: No such file or directory

Don’t forget to sudo if you’re in Ubuntu.

Step 3: WordPress Options
The last step is to change some options in the WordPress admin panel. Navigate to the “Options” -> “Permalinks” tab and select the option that looks like “http://www.yourdomain.com/2007/12/11/sample-post/”;

After fiddling with WordPress, you should be good to go! Shoot me some comments if you run into any problems.

2 comments

Make Code in WordPress Awesome

If you plan to show your code in a WordPress blog, then you absolutely have to get nextthing.org’s plugin. The plugin supports different languages as well as external file includes and downloading. It’s pretty awesome. Check it out:

or

sh: /usr/bin/states: No such file or directory

1 comment