title: Manually Enable Compression Using httpModule
body: <p>I'm trying to enable gzip compression on a site on our work intranet. Unfortunately, I don't have access to IIS, so any changes I make have been through web.config.</p>
  
  <p>The server is running IIS 6 and .NET 2.0. </p>
  
  <p>I enabled compression by adding an httpmodule</p>
  
  <pre><code>public class EnableCompression : IHttpModule
  {
      public void Init(HttpApplication application)
      {
          application.BeginRequest += 
              (new EventHandler(this.Application_BeginRequest));
  
      }
  
      private void Application_BeginRequest(Object source, EventArgs e)
      {
          HttpContext context = HttpContext.Current;
          context.Response.Filter = new GZipStream(context.Response.Filter, CompressionMode.Compress);
          HttpContext.Current.Response.AppendHeader("Content-encoding", "gzip");
          HttpContext.Current.Response.Cache.VaryByHeaders["Accept-encoding"] = true;
      }
  
  }
  </code></pre>
  
  <p>I registered in the web.config...</p>
  
  <pre><code>&lt;system.web&gt;
      &lt;httpModules&gt;
        &lt;add name="EnableCompression" type="EnableCompression"/&gt;
      &lt;/httpModules&gt;
  &lt;/system.web&gt;
  </code></pre>
  
  <p>Well, the above worked fine, except javascript and css files do not get compressed. From what I have found, I would have to add .js and .css to the application mappings in IIS 6, but of course I can't do that. </p>
  
  <p>Apparently this can be done via the web.config file, but I don't know how to do that. </p>
  
  <p>How can I enable compression for .js and .css files?  </p>