Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
805 views
in Technique[技术] by (71.8m points)

caching - IIS 7.5 remove etag headers from response

I know this question has been asked alot of times, however most of them were in 2009-2010.

I am pretty sure a while back a project I was working on removed them, however I cannot find any way to remove them at the moment.

So has there been any advances in this field? It seems crazy that microsoft has made IIS to not be able to easily configure these headers.

Currently have tried:

  • Adding a blank etag header to the web.config
  • Adding an etag with quotes inside to the web.config
  • Adding a blank etag header directly through IIS
  • Adding a custom module which removes an etag on BeginResponse
  • Same as above but for EndResponse
  • Same as both above but instead of removing an etag, make it empty

I hear there is an ISAPI filter you can get to remove them, but I cannot find it anywhere, and have no experience in writing one from scratch but may end up being the only way to do it.

Just so there is some reason why I want to remove Etags for everything. I let the clients cache everything (expires & last-modified) so once my static files are gotten from the server it never needs to query the server again until it expires. As if you use Etags you still need to make a request to the server for each file to find out if the tag still matches. So using the client cache you only make requests for the content you need.

I also have a versioning system in place so when a change happens the static content is then referenced as my.js?12345 rather than my.js?12344. Anyway the point is I currently believe removing Etags will greatly improve one of the bottlenecks on my current project.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can use the IIS Rewrite Module 2.0 to remove the ETag. The following rewrite rule should do it:

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

You can see an example image of the rule configuration in IIS Manager on my blog.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.8k users

...