How to use Brotli for response compression in ASP.Net Core – Info Web Dev
When working with RESTful services that leverage the ASP.Net Core 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 response 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.
- In the Visual Studio IDE, click on File > New > Project.
- Select “ASP.Net Core Web Application (.Net Core)” from the list of the templates displayed.
- Specify a name for the project.
- Click OK to save.
- Next, in the “New .Net Core Web Application…” window, select “API.”
- Specify “ASP.NET Core 2.1” as the version of the ASP.Net Core runtime to be used.
- Uncheck the “Enable Docker Support,” “Configure for HTTPS,” and “No Authentication” checkboxes. We won’t be needing these features.
- Click OK.
Article Prepared by Ollala Corp