Set up gzip in IIS 8 and Windows 8

2019-05-26 10:43发布

问题:

I created the default MCV4 website and hosted in my local IIS8 in widows 8 system under default web site.

http://localhost/MyWesite

in IIS manager "Compression" enabled dynamic content compression and static content compression. also disabled file size limit for compression so all js file sized are considered for compression (still gzip compression did not happen)

Is this the only system level gzip configuration?

Then next I tried to do website level change. I also edited the applicationHost.config file in C:\Windows\System32\inetsrv\config below are the change I did

<section name="httpCompression" allowDefinition="MachineToApplication" overrideModeDefault="Allow" />

in the web.config file I added the following

<system.webServer>
<httpCompression> 
  <staticTypes> 
    <add mimeType="text/*" enabled="true" /> 
    <add mimeType="message/*" enabled="true" /> 
    <add mimeType="application/javascript" enabled="true" /> 
    <add mimeType="application/x-javascript" enabled="true" /> 
    <add mimeType="image/jpeg" enabled="true" /> 
    <add mimeType="*/*" enabled="false" /> 
  </staticTypes> 
  <dynamicTypes> 
    <add mimeType="text/*" enabled="true" /> 
    <add mimeType="message/*" enabled="true" /> 
    <add mimeType="application/javascript" enabled="true" /> 
    <add mimeType="application/x-javascript" enabled="true" /> 
    <add mimeType="image/jpeg" enabled="true" /> 
    <add mimeType="*/*" enabled="false" /> 
  </dynamicTypes> 
  <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" dynamicCompressionLevel="4" /> 
</httpCompression>
</system.webServer>

After doing this I restarted iis just in case. On loading the webpage no js file or html document got gziped.

回答1:

Probably you have already fixed this issue, it just happened to me and I found this while looking for the error. I had the exact same web.config configuration (worked perfectly on older webserver with IIS 7.5).

I found that you need to go to Server Manager and make sure that you have setup the Dynamic Content Compression feature, under Web Server => Web Server => Performance.



标签: iis gzip