How do I remove eTag headers from IIS7?

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

Up vote 51 down vote favorite 19 share g+ share fb share tw.

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?

Asp.net iis7 etag link|improve this question edited Aug 9 '09 at 9:16Jeff Atwood?20.3k2688103 asked Jan 25 '09 at 16:44Brent Broome.

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".

I'm tempted to kill etags for a different reason: Unless I'm misperceiving things, I'm seeing IIS on a single server gratuitously change the first component of etags (i.e. The so-called "Filetimestamp") despite my file not being modified. For example, the latest version of a file will be in the browser, the browser will send up 'If-None-Match: "01cc3a8acccc1:0"'/'If-Modified-Since: Fri, 06 Jan 2012 00:32:24 GMT', and IIS will respond with 'ETag: "b6baeea8acccc1:0"'/'Last-Modified: Fri, 06 Jan 2012 00:32:24 GMT'.

These are js files w/ URLs like foo. Js? Rev=xxx, passing same xxx each time.

– Chris Jan 6 at 5:25 @Chris: I do very nearly the same thing, I allow js files to be cached and only change the xxx when the file is changed. I can't say that I've ever encountered the behaviour you are seeing on any version of IIS. Something is a bit odd with your IIS config I suspect.

– AnthonyWJones Jan 6 at 13:19 Thanks. As far as you know, is the "Filetimestamp" portion of etags based ONLY on the timestamp of the file being requested, and not on anything about the state of the machine/process/application? – Chris Jan 6 at 22:49 @Chris: As far as I know yes E-Tag is based on the file time only.

I've tried fiddling around with my server and I can't reproduce the problem you are seeing. – AnthonyWJones Jan 7 at 19:51.

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.

Using blank doesn't work, either. ETag is sent down anyway. Setting the ETag to blank quotes as other sites have suggested doesn't work.

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.

2 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 were available via the GUI) – Pure.

Krome Aug 25 '09 at 7:51 1 @Pure. Krome: The unlock, combined with Jeff's second attempt above, seems to work for me in most cases... except (of course! ) for image content.

:-\ ... So at least there seems to be a partial solution in here. – jerhewet Sep 8 '11 at 20:14 @jer you should add that as a proper answer – Jeff Atwood? Sep 8 '11 at 22:20.

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.

Yep, looking more and more like there's no other option. Accursed ETag.. – Jeff Atwood? May 17 '10 at 10:03.

I realize this is an old question, but I came across it while searching for a solution. I think I found a reasonable answer which I posted for this question.

Confirmed to work as long as you clear your cache after changing it ;) – peter3 Nov 11 '11 at 15:53.

I wrote a custom http module to handle this. It's really not as bad as it sounds. Here's the code: using System; using System.

Web; namespace StrongNamespace. HttpModules { public class CustomHeaderModule : IHttpModule { public void Init(HttpApplication application) { application. PostReleaseRequestState += new EventHandler(application_PostReleaseRequestState); } public void Dispose() { } void application_PostReleaseRequestState(object sender, EventArgs e) { HttpContext.Current.Response.Headers.

Remove("Server"); HttpContext.Current.Response.Headers. Remove("X-AspNet-Version"); HttpContext.Current.Response.Headers. Remove("ETag"); } } } Here's the web.

Config changes you'll want.

Check out this blog post on how to completely remove the Etag http header in iis6,iis7 and iis7.5 lightspeednow.com/blog/2010/05/21/iis-tu....

1 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 Jun 7 '10 at 15:17.

jesscoburn.com/archives/2008/10/02/quick... has a nice pictorial guide. Essentially, you create a custom response header named ETag and make its value empty.

2 I found this solution doesn't work for image files. – jwanagel Feb 5 '09 at 19:18 2 doesn't work, sadly – Jeff Atwood? Aug 9 '09 at 9:07 On IIS6, this only worked for me when I set no value not just two double quotes.

I.e. – Duncan Aug 10 '09 at 22:27.

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.

7 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?

Aug 9 '09 at 9:00 @JeffAtwood not strictly true, the browser will request the file if the user hits the refresh button, if the etag is the same you get a 304 if diff you get a 200, the issue here is that you send down 2 headers where 1 would have been enough – Sam Saffron? Mar 16 at 3:07.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions