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.






About The Author

Suprotim Agarwal
Suprotim Agarwal, Developer Technologies MVP (Microsoft Most Valuable Professional) is the founder and contributor for DevCurry, DotNetCurry and SQLServerCurry. He is the Chief Editor of a Developer Magazine called DNC Magazine. He has also authored two Books - 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!