I've just upgraded all my .net core packages to asp.net core 1.1. At the same time I thought I'd implement the newly released response compression middleware. However when I look in the browser dev tools (network traffic), I can see that the response is no different in size whether I use compression or not. Additionally there is no response header of type "Content-Encoding" indicating that compression occurred.
Is there anything else I should be doing here to make this work?
My code is as follow:
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddMvc(options => {
options.CacheProfiles.Add("Never",
new CacheProfile()
{
Location = ResponseCacheLocation.None,
NoStore = true,
Duration = 0
});
});
services.AddResponseCompression();
And:
public void Configure(IApplicationBuilder appBuilder)
{
appBuilder.UseResponseCompression();
appBuilder.UseMvc();
I think you need to specify the compression provider. Try this:
services.AddResponseCompression(options =>
{
options.Providers.Add<GzipCompressionProvider>();
});
When I do that I see a response that was previously 89kb go to 2kb and the content type and encoding are being set to expected values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With