如何使用IIS压缩所有文件 [英] How to compress all files with IIS

查看:111
本文介绍了如何使用IIS压缩所有文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IIS压缩已启用:

IIS compression has been enabled:

以下是web.config的httpCompression标记:

The following is the httpCompression tag of web.config:

<httpCompression
      directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files"
      minFileSizeForComp="1"
      staticCompressionIgnoreHitFrequency="true"
      dynamicCompressionIgnoreHitFrequency="true">
  <dynamicTypes>
    <add mimeType="*/*" enabled="true" />
  </dynamicTypes>
  <staticTypes>
    <add mimeType="*/*" enabled="true" />
  </staticTypes>
</httpCompression>  

我看到在运行Web应用程序时仅压缩了CSS和JavaScript文件:

I see only CSS and JavaScript files are compressed when running the web app:

不幸的是,其他文件未压缩:

Unfortunately, other files are not compressed:

我看不到"IIS临时压缩文件"在"C:\ inetpub \ temp"中.

I do not seee "IIS Temporary Compressed Files" in "C:\inetpub\temp".

任何人都可以提供有关如何诊断此问题的提示吗?

Could anyone provide a tip on how to diagnose this?

更新[2020-08-13] Windows Server 2016上的配置编辑器:

Update[2020-08-13] Configuration Editor on Windows Server 2016:

更新[2020-08-13] 对于每个@ Kul-Tigin,需要安装动态内容压缩:

Update[2020-08-13] Per @Kul-Tigin, Dynamic Content Compression needs to be installed:

推荐答案

  1. 没有名为dynamicCompressionIgnoreHitFrequency的设置,请将其删除.

  1. There's no such a setting named dynamicCompressionIgnoreHitFrequency, remove it.

1(以字节为单位)有点苛刻.压缩小文件只会减小响应大小. 将其保留为默认值2700.

1 (in bytes) for minFileSizeForComp is a little bit harsh. Compressing small files just decreases the response size. Leave it 2700 as default.

与设置属性值不同(就像您在staticCompressionIgnoreHitFrequency="true"中所做的一样),将设置添加为节点不会覆盖继承的设置.

Unlike setting values on attributes (like you did in staticCompressionIgnoreHitFrequency="true"), adding a setting as node won't override inherited ones.

在添加前,删除可能继承的对应设置或清除所有继承的设置是防止错误(尤其是无提示的错误)的一种好习惯.

否则,可能会发生错误,或者更严重的是,无提示错误可能会破坏您的设置.

Otherwise an error may occur or worse a silent error may break your setting.

100(以MB为单位)的空间限制可能不足以满足您的需求.如果我没记错的话,您的大多数文件都是megabaytes的Webassembly文件.

100 (in MB) for per application pools space limit may be insufficient for your needs. If I recall correctly most of your files are webassembly files of megabaytes.

由于您希望尽可能压缩所有文件;指定足够大的值.

Since you want all files to be compressed if possible; specify a value big enough.

尽可能大;所有文件的未压缩长度之和.说2048 MB.

Big as if possible; the sum of the uncompressed lengths of all your files. Say 2048 MB.

通过这种方式,您无法达到磁盘空间限制,因此不会由于空间不足而删除所有压缩的高速缓存.

With this way you can't reach the disk space limit so none of your compressed caches are not deleted due to lack of space.

只要原始文件没有更改,压缩的缓存就可以保留并交付.

As long as the original file has not changed, the compressed caches survive and be delivered.

我有3年的压缩高速缓存文件存储在我的服务器上,可以随时进行发送.

I have 3 years old compressed cache files stored on my servers, ready to be delivered BTW.

因此,请尝试以下操作.

So, give the following a try.

如果它不起作用,请提供有关请求标头和未压缩交付的文件的更多信息.

If it does not work, please provide more information about request headers and the files that are delivered as uncompressed.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpCompression 
        sendCacheHeaders="false" 
        directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" 
        doDiskSpaceLimiting="true" 
        maxDiskSpaceUsage="2048" 
        minFileSizeForComp="2700" 
        noCompressionForHttp10="true" 
        noCompressionForProxies="true" 
        noCompressionForRange="true" 
        staticCompressionIgnoreHitFrequency="true" 
        staticCompressionDisableCpuUsage="100" 
        staticCompressionEnableCpuUsage="50" 
        dynamicCompressionDisableCpuUsage="90" 
        dynamicCompressionEnableCpuUsage="50" 
        dynamicCompressionBufferLimit="65536">
          <dynamicTypes>
            <clear />
            <add mimeType="*/*" enabled="true" />
          </dynamicTypes>
          <staticTypes>
            <clear />
            <add mimeType="*/*" enabled="true" />
          </staticTypes>
        </httpCompression>  
    </system.webServer>
</configuration>

这篇关于如何使用IIS压缩所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆