In start up class , I added the below line to my asp.net core application
services.AddResponseCompression();
so configureServices method is looked like below
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<MyDBContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddCors(options =>
{
options.AddPolicy("AllowAll",
builder =>
{
builder
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});
services.AddMvc();
services.AddResponseCompression();
}
and also I added the below line to configure method
app.UseResponseCompression();
here is configure method
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseCors("AllowAll");
app.UseResponseCompression();
app.UseMvc();
}
now when I run the project , it works faster , size of response has been reduced and compressed (I checked it via chrome console Network tab ), it is the purpose of response compression Middleware to compress the response
My question is : Is there any cons of using this Middleware or Is there any situation that I should not use response compression ?