I’ve been tweaking the performance of BlogEngine.NEXT today using my favorite tool: YSlow for FireBug. One of the things YSlow checks for is the expires HTTP header for static content such as images, script files and style sheets. Since BlogEngine.NET has always used custom HTTP handlers for serving scripts and stylesheets, only the static images have been a problem.

The problem

The problem is that with images on hosted environments on IIS 6, it’s impossible to control the serving of them without redirecting them through an HTTP handler. That’s not a good idea for several reasons:

  • It adds unnecessary overhead by going through the ASP.NET ISAPI
  • You need to add custom code to handle the requests
  • You need to change the URL from .gif to .gif.axd or similar

Here is what YSlow finds on my website that needs the expires header set to a far future date:

As you can see, it is all my static images that lacks the expires header.

The solution

If you run IIS 6 there is no good way of adding an expires header to images unless you have control over the IIS. If your site is hosted then you probably have no control at all. If you are using IIS 7 however, you can very easily add the header in your web.config’s system.webServer section like so:

<staticContent>
 <clientCache httpExpires="Sun, 29 Mar 2020 00:00:00 GMT" cacheControlMode="UseExpires" />
</staticContent>

What happens is that all static content will now have an expires HTTP header set to the year 2020. Static content means anything that isn’t served through the ASP.NET engine such as images, script files and styles sheets. This is one of the very easy tricks that will increase the performance of your site as well as your YSlow score.

We’ve had a tradition of doing geek dinners in Copenhagen for the past 2 years. It’s always very good fun and there’s a bunch of interesting .NET guys to chat with. However, it has always been very intimate and most of the people going have been there before.

We need new blood and that’s why it’s time to take the geek dinner concept to the next level and the name is .NETworking dinner. The basic concept remains the same but in a much larger scale. It’s still an informal dinner arrangement with free beer, but this time I’m aiming for at least 50 people. This is important from a networking perspective.

The point is to meet a lot of new people in a relaxed atmosphere and talk about coding, business or just plain fun. Hopefully, that will help strengthen the Copenhagen .NET community and open up new opportunities.

Since numbers are important, please tell your colleagues and friends about this event and sign up to the event on Facebook. It’s Tuesday, April 21st after normal work hours and it's free.