Skip to content

Instantly share code, notes, and snippets.

@walm
Created March 22, 2011 19:23
Show Gist options
  • Save walm/881857 to your computer and use it in GitHub Desktop.
Save walm/881857 to your computer and use it in GitHub Desktop.
Gzip ASP.NET response
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment