Tips for Optimization: Integrate HTTP Compression with ASP.NET
30th Sep 2016
Definition of HTTP compression
Since the closing of the last century, most browsers have supported the process of compressed contents. Contents are compressed using the method of content encoding specified within HTML 1.1. During the process of browser request of a web page, it specifies if a particular content-encoding method is supported by it or if not then which kind is supported. As per that request, the server fulfills the browser demand. The information is communicated via ‘accept-encoding’ request header. If configured accurately, the server could respond to header value and would automatically compress HTTP content just before passing it to browser. After the arrival of content, the decompression process is performed by the browser that renders the page.
Advantage of HTTP compression
Primary aim of using the HTTP compression method is to reduce the byte numbers that is transmitted in between the server and the user machine. During the process of page loading, the overall transmission time is the main bottleneck behind its slow speed. Bandwidth is directly related with costs spent as site operator and by reducing the bytes of transmission, you not only save money but also improve site performance.
How to integrate HTTP compression with ASP.NET?
Many methods are there to blend HTTP compression along with ASP.NET in Software Development. If a user has complete access to server then using IIS6 would offer few basic compression support. By default, IIS6 offers HTTP compression for dynamic content. However, while compressing dynamic contents, one would need extra steps. User machines under the control of Windows Server 2008 could avail outstanding features offered by IIS7. This architecture lets you define file compression based on MIME method used in your configuration.
Hopefully, those developers who do not have direct access to IIS could implement alternative methods to deploy the support for HTTP compression. One may use either open source projects or commercial products that exist on interwebs to implement HTTPModules to compress the content on the basis of configuration rules.
First of all, add HttpModule reference to web.config and deploy a single assembly in the bin folder. Thereafter compress the HTTP content (served by either of the 2 architectures) via intelligent sets of rules.