IIS Content expiration header and ASP.NET

G

Guest

I have just stumbled upon an what seems to be a very under-rated feature in
IIS - the "Enable Content Expiration" option under a website's properties. I
have an ASP.NET web application that has a lot of subdirectories and each one
has its own set of images (I know its not best design practice, but there is
a business reason behind it). Many pages on the site have quite a few images
and there is a noticeable time lag each time the user navigates across pages,
even when the images are being loaded out of the IE cache. Presumably, this
was IE sending an "if-modified-since" request to the server and waiting for a
304 response before it served the image from the cache, for each image on the
page. Since the images dont change very often, adding an expires or maxage
header to the images would make a very big difference to the users. But how
was I to do it?

Then I thought of trying the "Enable Content Expiration" option in IIS. I
never used before as I thought it applying it on the application, would cause
IE to cache my dynamic ASP.NET pages. And it would be a maintenance headache
to do this for every image directory in the application, and then remember to
do this for every new subdirectory added later.

It turns out my assumption was wrong. After a lot of testing, it emerged
that IIS is smart enough to add the expiration header only to static content.
It automatically adds the header to images and css files, without touching
the aspx pages. This is brilliant! This is a great feature that everybody
should be using! It has made quite a difference to the user experience for
our application, as now images and CSS files are loaded very quickly straight
out of the IE cache.

Unfortunately, it had mixed experiences trying to set this up. I used
Fiddler to check the headers of incoming images and sometimes it would work
straight away, while other times I had to add and remove the option many
times before it finally worked. It was quite frustrating and I am not quite
sure why this was happening. I even tried resetting IIS, but that didnt help.

Also, how does IIS determine what extensions fall under static content? Is
there a way to modify this list?

Does anybody else here have any experience with this feature that they would
like to share?

Thanks
OS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top