IIS 7.5 从响应中删除 etag 标头 [英] IIS 7.5 remove etag headers from response

查看:30
本文介绍了IIS 7.5 从响应中删除 etag 标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题已经被问过很多次了,但大多数是在 2009-2010 年.

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.

那么这个领域有什么进展吗?微软让 IIS 无法轻松配置这些标头,这似乎很疯狂.

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.

目前已经尝试过:

  • 向 web.config 添加一个空白的 etag 标头
  • 将带有引号的 etag 添加到 web.config 中
  • 直接通过 IIS 添加一个空白的 etag 标头
  • 添加自定义模块以删除 BeginResponse 上的 etag
  • 同上,但用于 EndResponse
  • 与上面相同,但不是删除 etag,而是将其设为空

我听说有一个 ISAPI 过滤器可以删除它们,但我在任何地方都找不到它,并且没有从头开始编写过滤器的经验,但最终可能是唯一的方法.

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.

所以我想删除所有内容的 Etags 是有原因的.我让客户端缓存所有内容(过期和上次修改),因此一旦我的静态文件从服务器获取,它就永远不需要再次查询服务器,直到它过期.就像您使用 Etags 一样,您仍然需要为每个文件向服务器发出请求,以确定标签是否仍然匹配.因此,使用客户端缓存,您只能请求您需要的内容.

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.

我还有一个版本控制系统,所以当发生变化时,静态内容会被引用为 my.js?12345 而不是 my.js?12344.无论如何,关键是我目前相信删除 Etags 将大大改善我当前项目的瓶颈之一.

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.

推荐答案

您可以使用 IIS Rewrite Module 2.0 删除 ETag.以下重写规则应该这样做:

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>

您可以在我的博客上看到 IIS 管理器中规则配置的示例图像.

这篇关于IIS 7.5 从响应中删除 etag 标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆