2009-06-16 54 views
2

在YSlow的幫助下,我試着調整我的頁面。
我認爲,爲了獲得巨大收益,壓縮我的頁面是一件小事。 嘗試從here,here,herehere之後的所有內容YSlow仍然顯示我的頁面被壓縮。爲什麼我的網頁仍未被壓縮?

我在IIS6上使用asp.net mvc 1.0。

在我的global.asax中有以下規則,我確保我的靜態內容不被MVC處理。

routes.Clear(); 
// Turns off the unnecessary file exists check 
routes.RouteExistingFiles = true; 
// Ignore text, html, files. 
routes.IgnoreRoute("{file}.txt"); 
routes.IgnoreRoute("{file}.htm"); 
routes.IgnoreRoute("{file}.html"); 
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 
// Ignore the content directory which contains images, js, css & html 
routes.IgnoreRoute("Content/{*pathInfo}"); 
//Exclude favicon (google toolbar request gif file as fav icon which is weird) 
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.([iI][cC][oO]|[gG][iI][fF])(/.*)?" }); 

這將確保我的js和css文件是靜態可訪問的。

這些都是我的metabase.xml相關剪

<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/deflate" 
     HcCompressionDll="%windir%\system32\inetsrv\gzip.dll" 
     HcCreateFlags="0" 
     HcDoDynamicCompression="TRUE" 
     HcDoOnDemandCompression="TRUE" 
     HcDoStaticCompression="TRUE" 
     HcDynamicCompressionLevel="9" 
     HcFileExtensions="htm 
      html 
      txt 
      css 
      js 
      mvc" 
     HcOnDemandCompLevel="10" 
     HcPriority="1" 
     HcScriptFileExtensions="asp 
      dll 
      exe" 
    > 
</IIsCompressionScheme> 

<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/gzip" 
     HcCompressionDll="%windir%\system32\inetsrv\gzip.dll" 
     HcCreateFlags="1" 
     HcDoDynamicCompression="TRUE" 
     HcDoOnDemandCompression="TRUE" 
     HcDoStaticCompression="TRUE" 
     HcDynamicCompressionLevel="9" 
     HcFileExtensions="htm 
      html 
      txt 
      css 
      js 
      mvc" 
     HcOnDemandCompLevel="10" 
     HcPriority="1" 
     HcScriptFileExtensions="asp 
      dll 
      exe" 
    > 
</IIsCompressionScheme> 

(元:不知道我是否應該把這個對SO或SF)

+0

我不確定RO是什麼? – AnthonyWJones 2009-06-16 07:30:52

+0

機架溢出,堆棧溢出的IT姊妹站點。我一直忘記它真的叫什麼。 – 2009-06-16 07:44:37

回答

4

的問題是,壓縮擴展相關,您需要指定應該獲得靜態或動態壓縮的所有擴展。您可以通過分別查看HcFileExtensions和HcScriptFileExtensions屬性來看到這一點。

因此,對於MVC而言,如果你不需要文件擴展名,你就不會獲得動態內容的任何壓縮。由於IIS7使用mimeTypes列表來觸發壓縮,因此IIS7執行的操作有所不同。帶有集成管道的IIS7是我們真正希望放置MVC應用程序的地方。在IIS6中,它的可能性,但它的一個kludge和壓縮是傷亡之一。

編輯

對於記住,壓縮發生在一個單獨的線程,並觸發後的第一個請求到資源上IIS6熊靜態內容,第一個請求本身熄滅壓縮。隨後使用壓縮版本提供對資源的後續請求。