Friday 11 May 2012

HTTP Compression in ASP.NET

HTTP compression is used to compress contents from a Web server. Images used in the website are not in compressed format.

Statis HTML content contains only plain text and it is easy to compress.

There are mainly two types of compression

1)Gzip Compression:
 
    Gzip Compression is used on files which contains dynamic data eg .aspx,.asp etc.

2)Static Compression:

    Static compression is used on files such as .html,.htm,.txt,.doc which cannot be change frequently.


Follow below steps :


HTTP Compression in IIS 6


1. Enable web site compression in IIS.

a. Right-click the web sites folder, then select the Service tab.
b. Activate the compress application files checkbox.
c. Activate the compress static files checkbox.
d. Limit the maximum temporary directory size to the default value.

2. Add gzip.dll to Web Service Extensions in IIS.

a. Left-click the web service extensions folder.
b. In the right pane, click the link to add a new web service extension.
c. Enter something like “HttpCompression” for the extension name.
d. Click Add, then browse to C:\Windows\System32\inetsrv.
e. Find and select gzip.dll and click Open.
f. Activate the set extension status to allowed checkbox and click OK.

3. Edit Metabase.xml file can be found in the directory
C:\Windows\System32\Inetsrv\Metabase.xml

4. Edit below code to
<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/deflate"
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="0"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="FALSE"
HcDynamicCompressionLevel="0"
HcFileExtensions="htm
html
txt"
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="0"
HcFileExtensions="htm
html
txt"
HcOnDemandCompLevel="10"
HcPriority="1"
HcScriptFileExtensions="asp
dll
exe"
>
</IIsCompressionScheme>


In HcScriptFileExtensions add .aspx file
In HcFileExtensions add .js and .css


5. Restart IIS

It's that easy to enable compression of Web pages, JavaScript, CSS . I hope you find this code as useful as I have.

Follow This Blog !!!

Monday 30 April 2012

Hello world!!

I am working as a software engineer in Hinduja Interactive, after some time,  I finally get the time to start blogging about the technology i used.

Here i will share my thoughts on technology and software. I will start with Microsoft technologies like .NET or SharePoint.

I hope you find these interesting…

Follow This Blog !!!