How to use Brotli for response compression in ASP.Net Core – Info Web Dev

When working with RESTful services that leverage the ASP.Net Web API, the easy availability of CPU versus the scarcity of network bandwidth can be a good reason to use content compression. Content compression reduces bandwidth consumption and facilitates faster responses. Thus you can take advantage of compression middleware in ASP.Net Core to improve your application's performance.

There are many response compression frameworks available for use with .Net Core. Brotli is a relatively new compression algorithm that provides much improved compression results over Gzip or Deflate, and it is supported by most modern day web browsers including Google Chrome, Mozilla Firefox, Opera, and Microsoft Edge. This article presents a discussion on how we can work with Brotli in ASP.Net Core.

Getting started with Brotli in ASP.Net Core

The first thing you need to do is create a new ASP.Net Core project in Visual Studio. You should also ensure that the latest version of .Net Core is installed in your system. At the time of this writing, the latest version is .Net Core 2.1. Next, follow these steps to create an ASP.Net Core application in Visual Studio.

  1. In the Visual Studio IDE, click on File > New > Project.
  2. Select “ASP.Net Core Web Application (.Net Core)” from the list of the templates displayed.
  3. Specify a name for the project.
  4. Click OK to save.
  5. Next, in the “New .Net Core Web Application…” window, select “API.”
  6. Specify “ASP.NET Core 2.1” as the version of the ASP.Net Core runtime to be used.
  7. Uncheck the “Enable Docker Support,” “Configure for HTTPS,” and “No Authentication” checkboxes. We won't be needing these features.
  8. Click OK.

Article Prepared by Ollala Corp

You might also like
Leave A Reply

Your email address will not be published.