Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GZip response on IIS Express

I want to compress responses coming from my IIS Express driven web application. We're using IIS Express as local development webserver and IIS on staging and on our build machines. I have found many guides on enabling gzipped responses on IIS but none for IIS Express. Is it even possible?

like image 693
Phil Avatar asked Apr 11 '12 08:04

Phil


People also ask

How do I enable gzip in IIS?

GZip Compression can be enabled directly through IIS. So we go to the “Turn Windows features on or off” and select “Dynamic Content Compression” and click the OK button.

Does IIS support gzip?

IIS ships a default compression scheme provider gzip. dll: That supports both Gzip and Deflate compression. Is registered as the gzip scheme in applicationHost.


2 Answers

You can enable compression in IIS Express, just like for IIS.

  1. Start command prompt and go to IIS Express installation folder (%PROGRAMFILES%\IIS Express)

  2. Run following command

appcmd set config -section:urlCompression /doDynamicCompression:true

To add compression for JSON run the following two commands from the IIS Express installation directory:

appcmd set config /section:staticContent /+[fileExtension='.json',mimeType='application/json']

appcmd.exe set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json',enabled='True']" /commit:apphost

Make sure to restart IIS Express.

like image 58
vikomall Avatar answered Sep 18 '22 20:09

vikomall


For Visual Studio 2019 I found the above does not work, as the applicationhost.config file is unique to the project. This file is stored in .vs\<solution_name>\config\applicationhost.config. For VS 2017 it isnt in the solution subfolder.

Thus the solution for me was to replace <httpCompression/> with the following.

<httpCompression directory="%TEMP%\iisexpress\IIS Temporary Compressed Files">             <scheme name="gzip" dll="%IIS_BIN%\gzip.dll" />             <dynamicTypes>                 <add mimeType="text/*" enabled="true" />                 <add mimeType="message/*" enabled="true" />                 <add mimeType="application/x-javascript" enabled="true" />                 <add mimeType="application/javascript" enabled="true" />                 <add mimeType="application/json" enabled="true" />                 <add mimeType="*/*" enabled="false" />             </dynamicTypes>             <staticTypes>                 <add mimeType="text/*" enabled="true" />                 <add mimeType="message/*" enabled="true" />                 <add mimeType="application/javascript" enabled="true" />                 <add mimeType="application/atom+xml" enabled="true" />                 <add mimeType="application/xaml+xml" enabled="true" />                 <add mimeType="image/svg+xml" enabled="true" />                 <add mimeType="*/*" enabled="false" />             </staticTypes>         </httpCompression> 
like image 41
Aveer28 Avatar answered Sep 18 '22 20:09

Aveer28