Using Response Compression Middleware in ASP.NET Core
This post is about using Response Compression Middleware in ASP.NET Core. Long back I wrote blog post on Enabling GZip Compression in ASP.NET5. It was a custom middleware I implemented in DNX days. Now as part of ASP.NET Core 1.1 Preview 1, Microsoft introduced Response Compression Middleware in ASP.NET Core.
To use Response Compression Middleware, first you need to add the
Microsoft.AspNetCore.ResponseCompression package to your project.json file.
You can enable compression using the
ConfigureServices methods in the Startup.cs file.
Now you can restore the packages using
dotnet restore command, and run the application using
dotnet run command.
You can verify GZip compression enabled or not using Chrome developer tools. You can able to see something like this.
You can find more features and details about ASP.NET Core 1.1 Preview 1 release here
Happy Programming :)