Wednesday, September 12, 2012

ASP.NET Increase performance using GZIP

GZIP-compression will decrease the number of bytes sent by your server to any client.

I've test result to shoe you below.
Ziped aspx page will decrease from 9,733,736 bytes to 538,531 bytes,It means this page reduce to 5.96% of actual size.
If you have an internet connection 1Mb, It mean you can open page zipped page in 0.5 second and unzipped page is 9 seconds.

Before Zipped ASP.NET Increase performance by using GZIP

After Zipped ASP.NET Increase performance by using GZIP

Test result in C# here.

        //Declare DataTable
        DataTable dt = new DataTable("TableName1");
        //Add Column
        //Declare Datarow
        DataRow dr = null;
        for (int i = 0; i < 20000; i++)
            dr = dt.NewRow();
            dr["CustomerID"] = i.ToString();
            dr["CustomerName"] = i.GetTypeCode().ToString();
        ViewState["dt"] = dt;

        Response.Filter = new System.IO.Compression.GZipStream(Response.Filter, System.IO.Compression.CompressionMode.Compress);
        Response.AddHeader("Content-Encoding", "gzip");

Don't hesitate to email me zomdev.

No comments:

Post a Comment