问题
IIS compression has been enabled:
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>
I see only CSS and JavaScript files are compressed when running the web app:
Unfortunately, other files are not compressed:
I do not seee "IIS Temporary Compressed Files" in "C:\inetpub\temp".
Could anyone provide a tip on how to diagnose this?
回答1:
There's no such a setting named
dynamicCompressionIgnoreHitFrequency
, remove it.1
(in bytes) forminFileSizeForComp
is a little bit harsh. Compressing small files just decreases the response size. Leave it2700
as default.Unlike setting values on attributes (like you did in
staticCompressionIgnoreHitFrequency="true"
), adding a setting as node won't override inherited ones.Before adding, removing possibly inherited corresponding setting or clear all the inherited ones is a good practice to prevent errors (especially silent ones).
Otherwise an error may occur or worse a silent error may break your setting.
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.
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.
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>
来源:https://stackoverflow.com/questions/63088626/how-to-compress-all-files-with-iis