aspnet / BasicMiddleware

[Archived] Basic middleware components for ASP.NET Core. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
169 stars 84 forks source link

Compression not working depeding on User-Agent #334

Closed agustins closed 6 years ago

agustins commented 6 years ago

I have an Angular application using the new template from net core sdk 2.1.

With this configuration:

public void Configure(IApplicationBuilder app)
{
    app.UseResponseCompression();
    app.UseStaticFiles();
    app.UseSpaStaticFiles();
}

public IServiceProvider ConfigureServices(IServiceCollection services)
{
    services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
    services.AddResponseCompression();

    // In production, the Angular files will be served from this directory
    services.AddSpaStaticFiles(configuration =>
    {
        configuration.RootPath = "angular/out";
    });
}

if the User-Agent header is present in the header, content is not compressed:

wrong

Removing User-Agent header, response is compressed:

ok

Tratcher commented 6 years ago

User agent should not be a factor here. What happens if you don't use UseSpaStaticFiles?

agustins commented 6 years ago

Removing UseSpaStaticFiles the behaviour is the same. I don't know why, but removing "AppleWebKit/537.36 (KHTML, like Gecko)" from User-Agent, works.

muratg commented 6 years ago

Closing this. @agustins please let us know if you have a network trace that you can share.