Quickly Configure or Disable ETags in IIS7 or IIS6

With the move of my blog to a new server, so comes a few new tweaks. Fortunately, I’m on an Windows 2008 Hosting account and I have had delegation enabled so I can remotely manage all the features in my IIS7 website with the IIS7 manager (but more on that in a later post).

Earlier this year I fired up firebug and the Y!Slow application from Yahoo to really dial in my website’s performance. One of these changes was to disable ETags. On the IIS6 server I was on I found an ISAPI filter that I could load on the site and call it a day. Turns out there’s an even easier way to disable ETags. Before we go disabling ETags though it’s probably a good idea to learn just what they are.

Just what are ETags?

An Entity Tag is a validator which can be used instead of, or in addition to, the Last-Modified header. An entity tag is a quoted string which can be used to identify different versions of a particular resource.

By sending an entity tag you promise the recipient that you will not send the same ETag for the same resource again unless the content is ‘equal’ to what you are sending now (see below for what equality means).

The above was taken from the mod_perl documentation on Issuing Correct HTTP Headers. So basically an ETag is a unique identifier your webserver sends to a web browser and will only change that ETag if the content it’s assigned to is changed.

Here’s how it works in IIS

  1. Client request static resource (gif for example) for the first time. IIS serve it to client with response code 200. Resource stored in IE cache.
  2. Client make additional request for the same resource. IIS responds with code 304. Client use resource from IE cache.
  3. In some point in time, IIS service restarts.
  4. All subsequent requests from client for the same resource will end up with code 200 and file being downloaded on the wire. Why? What is happening?
  5. Situation will return to normal when client will clean IE cache.

The above taken from LangleyBen Leon’s blog. So any time the service restarts (and I need to check if this is affected by application pool restarts but I suspect it may be) the ETag is actually reset regardless to whether the content changed or not.

What Yahoo actually recommends is you use the Last-Modified-Date or set an Expires header.

How to disable ETags easily in IIS6 and IIS7

I’ll leave it up to you to decide if you want to disable your ETags or not and up to you to do the necessary research. I have decided to disable ETags and here’s how I’m going to do it. I’m going to add a custom header to web server named ETag with a value of “”  (nothing in there). So every item sent will have a blank ETag (and thus mission accomplished).

In IIS7 you do this as follows

First select HTTP Response Headers

image

Then add an HTTP Response Header as mentioned earlier called ETag with a value of “” (yes, that’s two double quotes):

image

Next browse your site with Firebug or some other tool and you’ll see the Etags are gone! No ISAPI’s, no use of a metabase editor, just a quick added header.

In IIS6 you would do this as follows:

From within the MMC you select the HTTP Headers tab

image

Select the Add button and enter a new HTTP Header

image

Enter Etag and “” and then click ok and close out the MMC saving your changes.

That’s all you need to do to disable your ETags.

author avatar
Jess
With a background in web development and web server administration dating back to 1994, Jess Coburn founded Applied Innovations in 1999. As CEO, he led the company to become a recognized leader in Windows Hosting, specializing in ASP.NET, E-Commerce, and advanced web application hosting. Under Jess's leadership, Applied Innovations became known for making cutting-edge technology accessible and affordable for businesses. Building on this success, Jess expanded his vision by founding QIT Solutions, a managed cloud, IT, and cybersecurity company, where he continues to leverage his extensive industry experience to deliver innovative and secure IT solutions to businesses.

4 thoughts on “Quickly Configure or Disable ETags in IIS7 or IIS6”

  1. Pingback: IIS Compression and Caching | dave.harris.net

  2. Pingback: IIS Optimization – segmentfault

  3. Pingback: How do I remove eTag headers from IIS7? | ASK AND ANSWER

Leave a Comment

Scroll to Top