Is there a way to set the gzip compression at the web.config level or can I only do this in the IIS management console?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Here try this: Sped my site up by about 400% percent. Worked on first try.
Activate GZip with web.config
<system.webServer>
<httpCompression directory="%SystemDrive%\inetpub\
temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
<dynamicTypes>
<add mimeType="text/*" enabled="true"/>
<add mimeType="message/*" enabled="true"/>
<add mimeType="application/javascript" 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="*/*" enabled="false"/>
</staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true"/>
</system.webServer>
回答2:
Yes you can enable compression with the web.config, as the article below shows- but it can depend on the permissions on the server allows sites.
You should note that dynamic compression (anything that needs to be processed before ti can be sent to the client) can increase the load on the server because its having to do compression on every single request.
IIS7 Compression
Edit: note this is for IIS7 (as you have tagged)
回答3:
It can be complicated or even impossible to modify the applicationHost.config on all environments.
So why not simply gzip in code as shown in this post http://laubplusco.net/gzip-svg-files-asp-net/