javascript - 为什么我的 javascript 文件有时压缩有时不压缩?(IIS Gzip 问题)

标签 javascript iis caching compression gzip

我在 iis 设置中为 javascript 文件启用了 gzip,这里是相应的配置部分。

<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
        <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" staticCompressionLevel="10" dynamicCompressionLevel="8" />
        <dynamicTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
  <add mimeType="application/soap+msbin1" 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/x-javascript" enabled="true" />
            <add mimeType="*/*" enabled="false" />
        </staticTypes>
    </httpCompression>

目前,当我下载我的 js 文件时,似乎有时服务器会返回 gzip 文件,有时则不会。我不知道为什么,也不知道如何调试。

如果一个文件已经被 gzip 过,它应该缓存在本地磁盘中,下次有人再次访问该文件时,iis 内核应该直接返回缓存的 gzip 文件而不用再次压缩它。是吗?

最佳答案

jaf,我自己弄明白了,iis 可能有一些错误。您可以设置 frequenthitthreshold 选项以强制脚本文件始终对文件进行 gzip 压缩。 我写了一篇关于这个错误的帖子,但它是中文的,这是谷歌翻译的版本 Why gzip not work in IIS7?

关于javascript - 为什么我的 javascript 文件有时压缩有时不压缩?(IIS Gzip 问题),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2779118/

相关文章:

javascript - Knockoutjs 跟踪 ajax 调用后的变化

javascript - 如何获取js当前所在文件夹?

javascript - 如何使用 d3.force 对散点图进行动态、非重叠标记

firefox - 如何清除 Firefox Quantum 中的 DNS 缓存?

javascript - 如何避免 Node.js & MongoDB & Redis 堆栈中的狗桩效应?

javascript - 动态加载Javascript

javascript - HTML/JS/Canvas - 在没有 base64 的情况下上传之前编辑图像的尺寸

ASP.Net 5 IIS : Failed to resolve the following dependencies

iis - IIS 上的 Gzip 压缩 - 无法使其工作

asp.net - IIS Url Rewrite 的 preCondition 属性上的模式 ="."是什么意思?