My Products
Help
omelhus
PARTNER

Add compression to the responses

by omelhus (Updated ‎16-05-2022 09:02 by omelhus PARTNER )
Status: Implementert

Hey,

 

I see that compression is still missing in the API. Especially the schema, which is 27MB, would benefit from adding compression. I'm guessing you're running the API on .NET 6, so adding compression should be straight forward.

 

 

var builder = WebApplication.CreateBuilder(options);
builder.Services.AddResponseCompression(options =>
{
    options.EnableForHttps = true;
});

builder.Services.Configure<BrotliCompressionProviderOptions>(options =>
{
    options.Level = CompressionLevel.Fastest;
});

 

And as the absolutely first middleware on the app builder

 

var app = builder.Build();
// this must come before all the other middlewares
app.UseResponseCompression();

 

 

4 Comments
by Marius Bancila

This is a good suggestion. I will add it to our backlog.

by Marius Bancila

This is now available in production.

omelhus
PARTNER
by omelhus

Awesome! This took the schema from 26.68 MB to 1.23 MB!

by Øyvind Årseth
Status changed to: Status: Implementert