IIS7에서 eTag 헤더를 제거하려면 어떻게합니까?
당 고성능의 웹 사이트에 대한 야후의 우수 사례 , 내가 직접 내 모든 캐싱을 관리하고 ETag를위한 필요가 없습니다 ... 그리고있어 (내 헤더에서 ETag를 제거하고자 할 때 / 나는 농장으로 확장해야하는 경우, 나는 그들이 사라지기를 정말로 바란다). Windows Server 2008에서 IIS7을 실행하고 있습니다.이 작업을 수행 할 수있는 방법을 아는 사람이 있습니까?
IIS7에서 Etag 변경 번호 (Etag 다음 부분)는 항상 0으로 설정됩니다.
따라서 서버의 Etag가 더 이상 동일한 파일에 대해 서버마다 다르지 않으므로 Yahoo 모범 사례가 더 이상 실제로 적용되지 않습니다.
IIS7에서 ETag 헤더를 실제로 억제 할 수 없기 때문에 전혀 조작하지 않는 것이 가장 좋습니다. 지금까지 가장 유용한 구성 규칙은 "기본값으로 인해 문제가 발생하지 않으면 그대로 두십시오"라는 것을 알았습니다.
web.config에서이 작업을 수행하면 IIS7에서 ETag를 비활성화 할 수 있다고 생각할 것입니다. 그러나 스니퍼 추적은 ETag가 어쨌든 전송되었음을 확인합니다.
<httpProtocol>
<customHeaders>
<remove name="ETag" />
</customHeaders>
</httpProtocol>
공백을 사용하는 것도 작동하지 않습니다. 어쨌든 ETag는 아래로 전송됩니다.
<httpProtocol>
<customHeaders>
<add name="ETag" value="" />
</customHeaders>
</httpProtocol>
다른 사이트에서 제안한대로 ETag를 빈 따옴표로 설정하면 작동하지 않습니다.
<httpProtocol>
<customHeaders>
<add name="ETag" value="""" />
</customHeaders>
</httpProtocol>
원인 더 있는 ETag 아래에 요청하실 수 있습니다 :
ETag : "8ee1ce1acf18ca1 : 0", ""
결론적으로, 적어도 사용자 정의 모듈을 작성하지 않고서는 IIS7에서 ETag를 죽이는 작업을 시도하거나 생각할 수 없습니다.
이를 처리하기 위해 사용자 지정 http 모듈을 작성했습니다. 소리만큼 나쁘지는 않습니다. 코드는 다음과 같습니다.
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");
}
}
}
원하는 web.config 변경 사항은 다음과 같습니다.
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By"/>
</customHeaders>
</httpProtocol>
<modules>
<add name="CustomHeaderModule" type="StrongNamespace.HttpModules.CustomHeaderModule"/>
</modules>
</system.webServer>
</configuration>
나는 이것이 오래된 질문이라는 것을 알고 있지만 해결책을 찾는 동안 발견했습니다. 이 질문 에 대해 게시 한 합리적인 답변을 찾은 것 같습니다 .
이 문제가 있었고 IIS 7에서 빈 사용자 지정 ETag 헤더를 설정하는 것조차 모든 파일 (예 : 이미지 파일)에 대해 작동하지 않았습니다. 우리는 ETag 헤더를 명시 적으로 제거하는 HttpModule을 생성했습니다.
업데이트 : @ChrisBarr 사용자 덕분에 URL 재 작성 모듈 요구 사항 추가
iis 6에서는 'ETag'= ""에 대한 사용자 정의 헤더를 추가 할 수 있습니다.
In IIS 7, after reading this thread and figuring that it was impossible without using a custom http module, I found that you can simply install Microsoft's URL Rewrite module and add an outbound rewrite rule as follows:
<outboundRules>
<rule name="Remove ETag">
<match serverVariable="RESPONSE_ETag" pattern=".+" />
<action type="Rewrite" value="" />
</rule>
</outboundRules>
This actually works, and you don't need a custom http module (dll). Unlocking the system.webServer configuration section and setting customHeaders, etc., does not work - at least in all the cases I tried. A simple outbound rewrite rule does.
By the way, when you use iis8 it's simple
<element name="clientCache">
<attribute name="cacheControlMode" type="enum" defaultValue="NoControl">
<enum name="NoControl" value="0" />
<enum name="DisableCache" value="1" />
<enum name="UseMaxAge" value="2" />
<enum name="UseExpires" value="3" />
</attribute>
<attribute name="cacheControlMaxAge" type="timeSpan" defaultValue="1.00:00:00" />
<attribute name="httpExpires" type="string" />
<attribute name="cacheControlCustom" type="string" />
<attribute name="setEtag" type="bool" defaultValue="true" />
</element>
IIS 8.0: To use or not to use ETag
http://www.jesscoburn.com/archives/2008/10/02/quickly-configure-or-disable-etags-in-iis7-or-iis6/ has a nice pictorial guide.
Essentially, you create a custom response header named ETag and make its value empty.
Check out this blog post on how to completely remove the Etag http header in iis6,iis7 and iis7.5
I Used the removeetag.dll
found on http://www.caspianit.co.uk/iis7-etag-problem/ and it worked perfectly.
hope it will work well for you too
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.
I think this will work .. I know remove and blank doesn't work.
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="ETag" value=" " />
</customHeaders>
</httpProtocol>
</configuration>
</system.webServer>
참고URL : https://stackoverflow.com/questions/477913/how-do-i-remove-etag-headers-from-iis7
'program tip' 카테고리의 다른 글
이름과 경로가 다른 파일에 Git 패치를 적용하는 방법은 무엇입니까? (0) | 2020.09.22 |
---|---|
CSS에서 : hover 역할을하는 인라인 스타일 (0) | 2020.09.22 |
파이썬의 sorted () 함수는 안정적입니까? (0) | 2020.09.22 |
Android : Bitmap recycle ()은 어떻게 작동합니까? (0) | 2020.09.22 |
왜 할 수 (0) | 2020.09.22 |