Yesterday, Simone wrote a post about the YSlow Firebug extension where he listed different websites and their YSlow performance ranking. My website was one of the sites he compared and as you can see from his list, it didn’t do all that well with a score of 52. It was actually 56, but I think he made a typo. There was only one thing to do and that was to do everything I could to improve my rank. I’m competitive, what can I say?

It really doesn’t make sense to be competitive with this, because YSlow suggest things that makes no sense for a regular website or blog, but I’ve managed to ignore common sense before so this was up my ally.

The work

Some of the things YSlow mentioned was the missing expire header on the WebResource.axd. I quickly wrote that into my HTTP compression module. Also, the CSS file needed HTTP compression, so I added that to the CSS HttpHandler I use. Then I improved the use of the ETag header as well along with optimizing the number of HTTP requests on the page.

After fiddling for a long time with compressing the WebResource.axd handler I gave up. I’m not sure it can be done in a simple manor, but if I find out it will be the first thing I’ll add as well.

The reward

The result was pleasant. I went from a ranking of 56 to 71. That’s an improvement of 27%. If you look at Simone’s list you’ll see that I now rank second just after Google and thereby beating the rest of the sites on the list. Ohh, I love the smell of victory in the morning (it is actually 11pm but it doesn’t have the same ring to it).

The challenge

Since Simone also wrote a list of the various blog platforms and their ranking, in which BlogEngine.NET was near the bottom based on my site alone, I have decided to take off my gloves and challenge him to a friendly duel. Since the fixes I did will benefit all BlogEngine.NET users, I want the good name of BlogEngine.NET redeemed. It is actually now at the very top of his list beating the competition (if one such exists in the open source world?).

So, Simone, consider you challenged to beat my YSlow ranking of 71. I used 4 hours on my fixes, including hitting a dead end on WebResource.axd compression, so I think it is fair that you cannot use more time than that either - a gentleman agreement. And remember that you also represent SubText since you are on the dev team. Good luck.

UPDATE: Simone just accepted my challenge. Check out the comments.

Many blogs have the ability to ping different ping-services, such as Ping-o-Matic, Feedburner and Technorati, whenever some content is created or updated. But it is not only blogs who can benefit from pinging these services. Almost all websites that is updated regularly can use this technique.

All these services use XML-RPC and the exact same format, so you can write a ping class ones and then just add whatever ping service URL later. I’ve written a very simple static ping class that can be used in any ASP.NET application.

The code

Here is the the three methods needed to send XML-RPC pings.

/// <summary>
/// Sends a ping to various ping services.
/// </summary>
public static void Send()
{
  Execute("http://ping.feedburner.com");
  Execute("http://rpc.pingomatic.com/RPC2");
}

/// <summary>
/// Creates a web request and with the RPC-XML code in the stream.
/// </summary>
private static void Execute(string url)
{
  try
  {
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
    request.Method = "POST";
    request.ContentType = "text/xml";
    request.Timeout = 3000;

    AddXmlToRequest(request);
    request.GetResponse();   
  }
  catch (Exception)
  {
    // Log the error.
  }
}

/// <summary>
/// Adds the XML to web request. The XML is the standard
/// XML used by RPC-XML requests.
/// </summary>
private static void AddXmlToRequest(HttpWebRequest request)
{
  Stream stream = (Stream)request.GetRequestStream();
  using (XmlTextWriter writer = new XmlTextWriter(stream, Encoding.ASCII))
  {
    writer.WriteStartDocument();
    writer.WriteStartElement("methodCall");
    writer.WriteElementString("methodName", "weblogUpdates.ping");
    writer.WriteStartElement("params");
    writer.WriteStartElement("param");
    // Add the name of your website here
    writer.WriteElementString("value", "The name of your website");
    writer.WriteEndElement();
    writer.WriteStartElement("param");
    // The absolute URL of your website - not the updated or new page
    writer.WriteElementString("value", "http://www.example.com");
    writer.WriteEndElement();
    writer.WriteEndElement();
    writer.WriteEndElement();
  }
}

Implementation

Download the class below and drop it into the App_Code folder or a class library. Then from anywhere in your ASP.NET project you can use the class by calling the Send method like so:

PingService.Send();

Because it can take some time to ping all the different services, you might want to consider doing it asynchronously. Here is how to do that. That’s it. Now you have a class that pings various services using XML-RPC. You can find a full list of available ping services here.

PingService.zip (816 bytes)