Click to Play

Guarantee Conversions on Your...
Given the economic environment we are all living in, businesses cannot afford to not have their landing pages convert. In this video from SES NYC, Tim Ash gives...

Recent Articles

Check Top Internet Browsers For Site Compatibility
I always test my sites in the latest crop of browsers - FF, IE, Safari (Mac and Win), Opera. I'm still supporting IE6, unfortunately, but once IE8 comes out I may put...

The De-Applefication of Web Design
The glossy button. The shiny floor. We've all done it. The iPhone is a groovy new gadget but it's perpetuating...

How To Properly Test Alt And Title Image Tags
Recently, I began a test of the ALT and Title elements in the img html tag. Here is the breakdown of the testing: 1. Conducting the research by creating a page on the topic...

Learning From The Mistakes Of TV Station Web Design
First things first. I know journalism is hard and that these folks never set out to be a web-centric organization. But the reality is that the audience is using the web...


03.30.09

Adding Expiration Date To Headers

By Mads Kristensen

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:



The Power, Control and Services You Need Wrapped
in the Expert Support You Want - Learn More

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:



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.

Comments


About the Author:
Mads Kristensen currently works as a Senior Developer at Traceworks located in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in 2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and web services in his daily work as well. A true .NET developer with great passion for the simple solution. http://www.madskristensen.dk/
About DesignNewz
A collection of articles and tutorials for professional web designers, DesignNewz features software reviews, helpful tips and shortcuts for design professionals of all skill levels.





DesignNewz is brought to you by:

WebProNews.com Jayde.com
MarketingNewz.com SalesNewz.com
ActivePro.com InvestNewz.com
eCommNewz.com WebsiteNotes.com
AdvertisingDay.com ManagerNewz.com
SoHoDay.com CRMNewz.com





-- DesignNewzis an iEntry, Inc. publication --
iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509
2009 iEntry, Inc. All Rights Reserved Privacy Policy Legal

archives | advertising info | news headlines | free newsletters | comments/feedback | submit article


DesignNewz Home Page About Article Archive News Downloads WebProWorld Forums Jayde iEntry Advertise Contact