Thursday, October 6, 2011

IIS 6.0 Compression

1) Backup the metabase. This is done by right-clicking on the server in the IIS snap-in and selecting All Tasks -> Backup/Restore Configuration.

2) Create Compression Folder (optional)

The first thing I do is create a folder on the D drive where the static file compression will be cached. You can call it anything you want or leave the default of “%windir%\IIS Temporary Compressed Files” if that works for you. The IUSR_{machinename} will need write permission to the folder. If you use custom anonymous users, make sure to assign the proper user. IIS will still work even if the permissions are wrong but the compression won't work properly. Once running, it's worth double checking Event Viewer to see if any errors are occurring that keep IIS Compression from working.

3) Enable Compression in IIS

- From the IIS snap-in, right-click on the Web Sites node and click on Properties
- Select the Service tab - Enable Compress application files
- Enable Compress static files
- Change Temporary Directory to the folder that you created above, or leave it at it's default
- Set the max size of the temp folder to something that the hard drive can handle. i.e. 1000.
- Save and close the Web Site Properties dialog

Note: The temporary compress directory is only used for static pages. Dynamic pages aren't saved to disk and are recreated every time so there is some CPU overhead used on every page request for dynamic content.

4) Metabase changes

To enable metabase edit-while-running using IIS Manager
  1. In IIS Manager, right-click the local computer, and then click Properties.
  2. Select the Enable Direct Metabase Edit check box.
- Open the metabase located at C:\Windows\system32\inetsrv\metabase.xml in Notepad
- Search for deflate and one for gzip. Basically they are two means of compression that IIS supports.
- First thing to do is add aspx, asmx, php and any other extension that you need to the list extensions in HcScriptFileExtensions.

HcDynamicCompressionLevel has a default value of 0. Basically this means at if you did everything else right, the compression for dynamic contact is at the lowest level. The valid range for this is from 0 to 10.

The compression level -vs- CPU usage which showed that the CPU needed for levels 0 - 9 is fairly low but for level 10 it hits the roof. Yet the compression for level 9 is nearly as good as level 10.

5) Restart IIS

Origianl Post : http://weblogs.asp.net/owscott/archive/2004/01/12/57916.aspx

Tuesday, October 4, 2011

Precompile an ASP.NET Web site in place

To precompile an ASP.NET Web site in place

  1. Open a command window and navigate to the folder containing the .NET Framework.

    The .NET Framework is installed in the following location.

    %windir%\Microsoft.NET\Framework\version
  2. Run the aspnet_compiler command by typing the following at a command prompt.

    aspnet_compiler -v /virtualPath

    The virtualPath parameter indicates the Internet Information Services (IIS) virtual path of your Web site.

    If your Web site is not an IIS application, and therefore has no entry in the IIS metabase, type the following command at a command prompt.

    aspnet_compiler -p physicalOrRelativePath -v /

    In this case, the physicalOrRelativePath parameter refers to the fully qualified directory path in which the Web site files are located, or a path relative to the current directory. The period (.) operator is allowed in the physicalOrRelativePath parameter. The -v switch specifies a root that the compiler will use to resolve application-root references (for example, with the tilde (~) operator). When you specify the value / for the -v switch, the compiler will resolve the paths by using the physical path as the root.