Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response Compression Example does not show anything useful #34419

Open
BillClarkEarthPoint opened this issue Dec 28, 2024 · 0 comments
Open

Response Compression Example does not show anything useful #34419

BillClarkEarthPoint opened this issue Dec 28, 2024 · 0 comments

Comments

@BillClarkEarthPoint
Copy link

BillClarkEarthPoint commented Dec 28, 2024

Description

https://learn.microsoft.com/en-us/aspnet/core/performance/response-compression?view=aspnetcore-8.0#azure-deployed-sample

I can see where the compressors are set up, but where are they shown being used?

The example is, with notes added
using Microsoft.AspNetCore.ResponseCompression;
using ResponseCompressionSample;

var builder = WebApplication.CreateBuilder(args);

//MY NOTE -- Here the compressors are set up
//but where are they used????
//Which responses are compressed, and which compression methods are used???

builder.Services.AddResponseCompression(options =>
{
options.EnableForHttps = true;
options.Providers.Add();
options.Providers.Add();
options.Providers.Add();
options.MimeTypes =
ResponseCompressionDefaults.MimeTypes.Concat(
new[] { "image/svg+xml" });
});

var app = builder.Build();

app.UseResponseCompression();

//MY NOTE -- Do any of the following use compression?
//If so, how, and which compression is used?
//Thank you....

app.Map("/trickle", async (HttpResponse httpResponse) =>
{
httpResponse.ContentType = "text/plain;charset=utf-8";

for (int i = 0; i < 20; i++)
{
    await httpResponse.WriteAsync("a");
    await httpResponse.Body.FlushAsync();
    await Task.Delay(TimeSpan.FromMilliseconds(50));
}

});

app.Map("/testfile1kb.txt", () => Results.File(
app.Environment.ContentRootFileProvider.GetFileInfo("testfile1kb.txt").PhysicalPath,
"text/plain;charset=utf-8"));

app.Map("/banner.svg", () => Results.File(
app.Environment.ContentRootFileProvider.GetFileInfo("banner.svg").PhysicalPath,
"image/svg+xml;charset=utf-8"));

app.MapFallback(() => LoremIpsum.Text);

app.Run();

Page URL

https://learn.microsoft.com/en-us/aspnet/core/performance/response-compression?view=aspnetcore-8.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/performance/response-compression.md

Document ID

2d56d9b6-3d7b-0204-6c08-8e584fccecc2

Article author

@tdykstra

Related Issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant