我正在使用seo優化和yslow優化我們公司的網站。 但在伊斯洛的ETAGS是F. 我已經經歷了數十個網站和教程,最好的選擇是使用HTTP模塊。 我已經這樣做了,並嘗試了幾個模塊,但沒有顯示results.maybe語法的東西是錯誤的或我註冊它錯了。有人說,最好使用app_PostReleaseRequestState而不是OnPreSendRequestHeaders,因爲在堆中崩潰。我是兩者都沒有結果。 那就是: 文件名是ETAG,它是在應用程序代碼文件夾在asp.net中使用Http模塊配置ETags
web配置:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add type="CompressionModule" name="CompressionModule"/>
<add type="ETags" name="ETags"/>
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</modules>
</system.webServer>
這裏是代碼:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
/// Summary description for ETags
/// </summary>
public class ETags : IHttpModule
{
public void Dispose() { }
public void Init(HttpApplication app)
{
app.PostReleaseRequestState += new EventHandler(app_PostReleaseRequestState);
}
void app_PostReleaseRequestState(object sender, EventArgs e)
{
HttpContext.Current.Response.Headers.Remove("ETag");
HttpContext.Current.Response.Headers.Remove("Server");
HttpContext.Current.Response.Headers.Remove("X-AspNet-Version");
HttpContext.Current.Response.Headers.Remove("X-Powered-By");
}
//public void Init(HttpApplication context)
//{
// context.PreSendRequestHeaders += OnPreSendRequestHeaders;
//}
//void OnPreSendRequestHeaders(object sender, EventArgs e)
//{
// HttpContext.Current.Response.Headers.Remove("ETag");
// HttpContext.Current.Response.Headers.Remove("Server");
// HttpContext.Current.Response.Headers.Remove("X-AspNet-Version");
// HttpContext.Current.Response.Headers.Remove("X-Powered-By");
//}
}
謝謝您的回答。
嗨感謝的建議,但:1,我加你的HTTP的Web配置並沒有什麼。這協議是從微軟的網站分析標題:內容編碼: 的Content-Length:7103 緩存控制:私人 內容 - 類型:text/html; charset = utf-8 Date:Mon,09 Jul 2012 13:50:17 GMT X-AspNet-Version:4.0.30319 2。 ETAGs仍然在那裏檢查你自己[鏈接](http://imi5.com)3.第二個(靜態內容被分離地添加到所有子內容的子內容) – 2012-07-09 12:53:40
@imijan但什麼? – Aristos 2012-07-09 12:55:39
i'gonna發佈了一些鏈接,指向其他人如何解決問題 – 2012-07-09 13:11:40