tags:

views:

5070

answers:

10

Per Yahoo's best practices for high performance web sites, I'd like to remove Etags from my headers (I'm manually managing all my caching and have no need for Etags... and when/if I need to scale to a farm, I'd really like them gone). I'm running IIS7 on Windows Server 2008. Anyone know how I can do this?

A: 

http://www.jesscoburn.com/archives/2008/10/02/quickly-configure-or-disable-etags-in-iis7-or-iis6/ has a nice pictorial guide.

Essentially, you create a custom response header named ETag and make its value empty.

Sören Kuklau
I found this solution doesn't work for image files.
jwanagel
doesn't work, sadly
Jeff Atwood
On IIS6, this only worked for me when I set no value not just two double quotes. i.e. <httpProtocol> <customHeaders> <add name="ETag" value="" /> </customHeaders></httpProtocol>
Duncan
+11  A: 

Under IIS7 the Etag change number (the part of the Etag following : ) is always set to 0.

Hence the Etag from the server no longer varies from server to server for the same file and therefore the Yahoo best practice no longer really applies.

Since you can't actually suppress the ETag header on IIS7 it would probably be best that you don't fiddle with it at all. I've found by far the most useful configuration rule is "If the default doesn't break something, leave it alone".

AnthonyWJones
+3  A: 

We had this problem, and even setting a blank custom ETag header in IIS 7 was not working for all files (for example image files). We ended up creating an HttpModule that explicitly removes the ETag header.

jwanagel
yep, looking more and more like there's no other option. Accursed ETag..
Jeff Atwood
A: 

In IIS 7 you shouldn't have to worry about etags anymore as the IIS configuration number is always set to 0.

There is still a problem if you have IIS6 & IIS7 webservers in the same farm. In this case you would have to manually set the IIS6 config number to 0 as described in this article.

Etags are actually very useful as you don't need to change the filename like stack overflow does (i.e. default.css?1234). If you change the default.css file it will change the etag and therefore subsequent requests will get the file from the server and not the cache.

Alex
far-forward expiration dates make ETags irrelevant, since the browser will literally never request the file again until the specified date (or until the filename changes, of course.) Thus, the need to remove it -- it's obsolete in that scenario.
Jeff Atwood
+6  A: 

You would think doing this in the web.config would work to disable ETags in IIS7. But sniffer trace confirms that ETag is sent down anyway.

<httpProtocol>
    <customHeaders>
        <remove name="ETag" />
    </customHeaders>
</httpProtocol>

Using blank doesn't work, either. ETag is sent down anyway.

<httpProtocol>
    <customHeaders>
        <add name="ETag" value="" />
    </customHeaders>
</httpProtocol>

Setting the ETag to blank quotes as other sites have suggested doesn't work.

<httpProtocol>
    <customHeaders>
        <add name="ETag" value="&quot;&quot;" />
    </customHeaders>
</httpProtocol>

Causes even more ETag to be sent down:

ETag: "8ee1ce1acf18ca1:0",""

In conclusion, nothing I can try or think of works to kill ETag on IIS7, at least without writing custom modules, etc.

Jeff Atwood
I've not confirmed this Jeff, but could this be because the httpProtocol section is locked at the website level. I found this the case when i was trying to programattically set the iis7 *compression* level via the web.config file. I had to finally *unlock* that section on the root server level. Maybe this section has the same problem? (I really wish ALL IIS settings are available via the GUI .. so this stuff is easy to manage and solve) ... <-- ZOMG .. a War-n-Peace comment reply. soz.
Pure.Krome
A: 

I've run into this problem too, but this article seems to solve my ETag issue. Jeff, does this help?

http://support.microsoft.com/?id=922733

Joe Basirico
er, that's for IIS 5.0. What year is it again? :)
Jeff Atwood
+1  A: 

If you only serve content from one server, then leave the Etags there, they won't hurt. Instead, configure the YSlow profile to not count for them when assessing the performance. See the Edit button near the Rulesets select element in the YSlow tab. Then uncheck the option regarding ETags from the YSlow(V2) profile.

Ionuț G. Stan
A: 

I know this might cause a bit of monkey work but has .Net's Response.Cache.SetETag(string) method been of use to anyone ?

bizl
A: 

In IIS 7 you shouldn't have to worry about etags anymore as the IIS configuration number is always set to 0.

NOT TRUE! I'm getting ETags for ALL content on my Server 2008 R2 and they're not 0 (zero) and the MDUTIL mentioned earlier doesn't work either.

chris
+2  A: 

Check out this blog post on how to completely remove the Etag http header in iis6,iis7 and iis7.5

http://lightspeednow.com/blog/2010/05/21/iis-tutorial-how-to-completely-remove-etags-entity-tags-from-iis6-iis7-and-iis7-5/

Brian
That requires a 3rd party plug in called Helicon Ape. Really we need a solution that uses the native IIS config, not an extra plug in. This is especially true for any large scale web farm, which is exactly where the ETag is the biggest problem.
Keith