views:

325

answers:

1

With the help of YSlow I'm trying to tune my pages a bit.
I thought it would be little effort for big gain to have my pages compressed. After trying everything from here, here, here and here YSlow is still showing my pages are nog compressed.

I'm using asp.net mvc 1.0 on IIS6.

With the following rules in my global.asax I make sure that my static content is not handled by 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])(/.*)?" });

This will make sure that my js and css files are statically accessible.

These are the relevant snips of my 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>

(meta: not sure if I should be putting this on SO or on SF)

+2  A: 

The problem is that compression is extension related, you need to specify all the extensions that should get either static or dynamic compression. You can probably see this by looking at the HcFileExtensions and HcScriptFileExtensions attributes respectively.

So with MVC shoe-horned into IIS6 where you don't necessarily have file extensions you will not be getting any compression for dynamic content. IIS7 does things differently since it uses a list of mimeTypes to trigger compression. IIS7 with integrated pipeline is where we're really expect to be placing MVC apps. In IIS6 its possible but its a kludge and compression is one of the casualties.

Edit

For static content on IIS6 bear in mind that compression happens on a separate thread and triggered after the first request to resource, the first request itself goes out uncompressed. Subsequent requests for the resource should then be supplied using the compressed version.

AnthonyWJones
My static content (javascript, css etc) is not handled by mvc and has regular extentions so I would guess it could benefit from the compression.I updated OP to answer your remark.
borisCallens