I am struggling with setting up the response compression for an endpoint in .net core 6 API that returns a relatively large sqlite file (>60mb) of type application/vnd.sqlite3.
I adde necessary configuration to Startup.cs class, such as
app.UseResponseCompression();
and
services.AddResponseCompression(options =>
{
options.Providers.Add<BrotliCompressionProvider>();
options.Providers.Add<GzipCompressionProvider>();
options.MimeTypes =
ResponseCompressionDefaults.MimeTypes.Concat(
new[] { "application/vnd.sqlite3" });
options.EnableForHttps = true;
});
services.Configure<GzipCompressionProviderOptions>(options =>
{
options.Level = CompressionLevel.SmallestSize;
});
response is returned from the controller like this:
return File(dataBytes, "application/vnd.sqlite3");
Even though response contains a header Content-Encoding with gzip/br (depending on request header), the size of a response is essentially the same as without compression.