Search code examples
asp.net-corecompressionbrotli

asp.net core 2.2 brotli compression not working on IIS?


I read in Asp.Net Core 2.2 documentation, brotli compression is added to 2.2.

I have app.UseResponseCompression(); and services.AddResponseCompression(); in my Startup.cs but when I tried it on my system with latest Chrome browser, I see only gzip compression at response headers. I host my Asp.Net Core 2.2 app on Windows Server 2012 IIS web server.

What should I config to get working brotli compression?

dev tools screenshot


Solution

  • If you're hosting in IIS then that means IIS is the webserver that's communicating with the browser. It sits in front of your ASP.NET Core app and proxies all requests and responses, but it doesn't support Brotli by default.

    You need to configure response compression with IIS. There's an extension available for adding Brotli and Zlib support: https://learn.microsoft.com/en-us/iis/extensions/iis-compression/iis-compression-overview

    You can also run your ASP.NET Core app without IIS.