:::: MENU ::::

Enabling GZip Compression in Asp.Net Core 1.1 application

Asp.Net Core 1.1 now provides GZip Compression middleware. GZip is a method of compressing files (making them smaller) for faster network transfers. Compression allows your web server to provide smaller files sizes which load faster for your users.

Let’s see how to implement this middleware in core 1.1 application.

First you need to add Compression  package from nuget in project.json file.

Now configure GZip services in ConfigureServices method in startup.cs file.

Then put it in Http pipeline inside Configure method.

That’s it. Now lets check the difference of our application file size with and without this middleware. For test purpose I  use MVC boilerplate application with no authentication.

Before GZip Middleware:

After GZip Middleware:

Wow!!! now its half of my original file size.

You can also configure this middleware for other options like enabling compression over HTTPS connection, compression for different MIME types and other compression providers.

Inside ConfigureServices Method:

That’s it. This is how you can use GZip compression in AspNet Core 1.1 application.

Happy Coding 🙂