Responses not being dynamically compressed when hosting ASP.NET Core in IIS

Viewed 237

I am hosting an ASP.NET Core application in IIS using Kestrel and the ASP.NET Core Server Hosting Bundle, and even though Dynamic Compression is enabled in IIS the responses are not returning back as compressed. Does anything need to be enabled within the application itself for dynamic compression to work or is there anything else within IIS that need to be enabled?

1 Answers

Adding the following to the web.config helped, as it appeared that application/json wasn't being compressed based on the default settings in IIS:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
      <httpCompression>
         <dynamicTypes>
             <add mimeType="application/json" enabled="true" />
          </dynamicTypes>
      </httpCompression>
    </system.webServer>
</configuration>
Related