as you don't show the response headers, we can not tell if it worked. check that the gzip accept header was sent, also check the content-encoding response header (should be gzip)
also check that you are not using http/2 which has compression built in and does not use gzip.
Please do not make the community guess what your doing. At least share your code, tell us what version of Core you are targeting, explain how you are testing, and the steps to reproduce this behavior..
Member
177 Points
629 Posts
Gzip compression doesn't work in Web Api Core
Mar 12, 2020 03:21 PM|neoaguil17|LINK
Hi
I applied compression in web api core, but I see the same result with and without compression:
I followed the link:
https://hanssens.com/recipes/enabling-gzip-compression-in-a-dotnet-core-webapi/
All-Star
58164 Points
15647 Posts
Re: Gzip compression doesn't work in Web Api Core
Mar 12, 2020 03:51 PM|bruce (sqlwork.com)|LINK
as you don't show the response headers, we can not tell if it worked. check that the gzip accept header was sent, also check the content-encoding response header (should be gzip)
also check that you are not using http/2 which has compression built in and does not use gzip.
All-Star
53001 Points
23594 Posts
Re: Gzip compression doesn't work in Web Api Core
Mar 12, 2020 03:57 PM|mgebhard|LINK
Please do not make the community guess what your doing. At least share your code, tell us what version of Core you are targeting, explain how you are testing, and the steps to reproduce this behavior..
https://docs.microsoft.com/en-us/aspnet/core/performance/response-compression?view=aspnetcore-3.1
Member
177 Points
629 Posts
Re: Gzip compression doesn't work in Web Api Core
Mar 13, 2020 12:06 AM|neoaguil17|LINK
Hi
This is the response...
I don't see content-encoding: gzip in the response.
Contributor
3140 Points
983 Posts
Re: Gzip compression doesn't work in Web Api Core
Mar 13, 2020 04:07 AM|Yang Shen|LINK
Hi neoaguil17,
The link article you provied, missed a very important thing for your situation that you have to set EnableForHttps to be true.
public void ConfigureServices(IServiceCollection services) { // Configure Compression level services.Configure<GzipCompressionProviderOptions>(options => options.Level = CompressionLevel.Optimal); // Add Response compression services services.AddResponseCompression(options => { options.EnableForHttps = true; options.Providers.Add<GzipCompressionProvider>(); }); services.AddControllers(); }
Best Regard,
Yang Shen
Member
177 Points
629 Posts
Re: Gzip compression doesn't work in Web Api Core
Mar 13, 2020 02:36 PM|neoaguil17|LINK
Hi
I did it but the response has the same time and size.
Member
177 Points
629 Posts
Re: Gzip compression doesn't work in Web Api Core
Mar 13, 2020 03:02 PM|neoaguil17|LINK
Hi
I identify that gzip compression doesn't work in iis express, it only works in IIS onpremise or azure appservice.