Compress Session State in ASP.NET 4

ASP.NET 4 introduces a new option called ‘compressionEnabled’ to compress session state and improve application performance.

When you are storing session state in a State Server or SQL Server and have set the ‘compressionEnabled’ attribute to true, ASP.NET compresses session-state data. I have heard that internally it uses the GZip stream to compress and decompress session data.

Add the following entry in your web.config file with the compressionEnabled attribute set to true, as shown below:

compressionEnabled web.config

Note: Since Compression and Decompression is involved, your application will consume additional CPU cycles to perform the operation. However compressing session state will lead to better performance of your application.



Will you give this article a +1 ? Thanks in advance


About The Author

Suprotim Agarwal
Suprotim Agarwal, ASP.NET Architecture MVP (Microsoft Most Valuable Professional) works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He is the Editor of a Developer Magazine called DNC Magazine. He has also written two EBooks 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook

Follow him on twitter @suprotimagarwal

2 comments:

Anand From Dominos Pizza said...

Compression enabled a new concept pretty interesting.

Fabian Fernandez said...

Good post!