# yslow says etags are misconfigured. how to configure etags properly on IIS7?

running ySlow on a website I support, I noticed it reported that the etags are misconfigured for the site images (e.g. *.jpg, *.png, *.gif). Can anyone help explain what I have to do to get IIS7 issuing these etags correctly ?

The accepted answer by Farseeker does not work. I've tested this in IIS 7.0.6000.16386 on Windows Server 2008 Standard SP 2.

See Jeff Atwood's comment on Stack Overflow for the same question.

Etags are OK as long as you don't serve content from multiple servers. If you only serve from one server, then leave them there. They don't hurt. And if you don't want YSlow to complain about them, then click the Edit button near the Rulesets select element and edit the YSlow(V2) profile. Just uncheck the "Configure entity tags (Etags)" option.

• +1 YSlow complains about a lot of things don't affect "mere mortal" web sites. (No YSlow, I don't have and don't need a CDN. Please quit whining already.) – Gerald Combs Feb 8 '10 at 21:21
• True about the rule set change. – MikeJ Jan 4 '12 at 17:10

YSlow is not complaining that they're wrong (even though that's what it says), but it's complaining that they're not needed. The only way to get YSlow to shut up about this is to disable them.

The good thing is, I just did this myself earlier today!

Open your IIS manager, click on the server, and go to HTTP Response Headers. Click the "Add..." button, and under name, enter:

ETag


(case sensitive). Under Value, enter

""


(thats two double quotes)

And ETags begone!

• As others point out, you should only remove ETags if you know you need to; in many cases, this won't be the case. – Bobby Jack Apr 8 '10 at 11:42
• That may be the case, but the fact of the matter is that the answer correctly answers the question. – Mark Henderson Apr 8 '10 at 11:56
• The question asked 'how do I get IIS7 to issuie these etags correctly?'. Your answer was to stop issuing ETags altogether, which is a possible performance hit, and likely unnecessary (there was no mention of CDN-usage in the question). – Bobby Jack Apr 8 '10 at 12:10
• @Bobby: the OP is implicitly asking "how do I get IIS7 to issue these etags correctly as defined by YSlow?". and the only "correct" configuration, as far as YSlow is concerned, is to disable them. – Kip Sep 15 '10 at 19:38
• @Kip, no, the implicit part is implicit, and you cannot guess it. But presuming that the OP is a reasonable person, he probably wanted to say "according to YSlow the configuration seems to be suboptimal, how can I make it optimal?" - And then this answer is a bit funny. It's like "why does my unit test complain?" - "Just delete the unit test, and it won't complain anymore!" – chiccodoro Jun 15 '11 at 8:09

See a similar StackOverflow Question.

In iis 6, you can add a custom header for 'ETag' = ""

In iis 7, add an outbound rewrite rule as follows:

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


IIS 7 will overwrite custom headers, and all other solutions proposed in various other answers regarding the same problem. Outbound rules are the only item that seems to work as it overwrites anything that's set just before it's returned to the user. This proposed outbound rule matches any server variable named RESPONSE_ETag as long as the value of RESPONSE_ETag has one or more characters and rewrites the value to be an empty string.

Please see the answer to Set Server response header in IIS7 for a partial solution. Yes, a complete solution would be really nice, but I'll take what I can get.

Better use this :

<outboundRules>
<rule name="Remove ETag">
<match serverVariable="RESPONSE_ETag" pattern="(.*)\:(.*)" />
<action type="Rewrite" value="{R:1}" />
</rule>
</outboundRules>

• Welcome to Server Fault! While the magic bytes are certainly nice, it's awesome for other people reading it if you explain why this is correct. – Falcon Momot Nov 8 '13 at 9:30