20

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 ?

7 Answers 7

7

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.

1
  • This answer is no longer correct/relevant. You can change ETags in iis 7+ by adding an outbound rule as seen in my answer serverfault.com/a/528346/78230
    – AndrewPK
    Dec 23, 2013 at 19:27
12

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.

2
  • 7
    +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.) Feb 8, 2010 at 21:21
  • True about the rule set change.
    – MikeJ
    Jan 4, 2012 at 17:10
11

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!

7
  • 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, 2010 at 11:42
  • 1
    That may be the case, but the fact of the matter is that the answer correctly answers the question. Apr 8, 2010 at 11:56
  • 1
    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, 2010 at 12:10
  • 2
    @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, 2010 at 19:38
  • 1
    @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, 2011 at 8:09
4

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.

1
  • Adding the outbound rule worked for IIS 10 as well, while nothing else would.
    – ahwm
    May 13, 2020 at 15:38
3

See a similar StackOverflow Question.

2

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.

1

Better use this :

<outboundRules>
  <rule name="Remove ETag">
    <match serverVariable="RESPONSE_ETag" pattern="(.*)\:(.*)" />
    <action type="Rewrite" value="{R:1}" />
  </rule>
</outboundRules>
1
  • 3
    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. Nov 8, 2013 at 9:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .