How to remove the IIS ETag HTTP header in IIS 7 / 7.5 (75)

I love my Kindle

If you prefer to not send the ETag HTTP header for files served from IIS 7 or 7.5, it is a bit problematic. To the best of my knowledge, IIS does not provide a straight forward way to remove this header. This post shows a way to do it using Microsoft's URL Rewrite Module 2.0.

I'm not going to go into the what and why of the ETag. Suffice it to say, many web developers and web masters would prefer not to send it.

The ETag can be removed using an outbound URL rewrite rule. You can read more about it at the URL Rewrite Module 2.0 Configuration Reference .

The rewrite rule that can be put in your web.config follows:

   
<rewrite>
   <outboundRules>
      <rule name="Remove ETag" >
         <match serverVariable="RESPONSE_ETag" pattern=".+" />
         <action type="Rewrite" value="" />
      </rule>
   </outboundRules>
</rewrite>
   

This graphic shows the settings for the ETag removal rewrite rule in IIS Manager. In fact, if you look at the headers for the image, you'll see there is no ETag :-)

Remove ETag HTTP Header IIS Manager

If you happen to be using Helicon's Ape, then this is very simple as well. You can use a mod_headers rule like:

      Header set ETag ""
   

I hope this helps :-)

IIS Technical November 10, 2011

comments powered by Disqus