首页 文章

如何在asp.net应用程序中进行GZIP压缩?

提问于
浏览
2

我正在使用PageSpeed Insights在我的asp.net应用程序中进行页面优化,并且发现我需要将所有请求压缩为Gzip格式以减小大小和加载时间 .

但是,当我在网络中检查了请求时,它显示我在 Request-headerResponse-Header 中已经分别有 Accept-Encoding:gzip,deflate,sdchContent-Encoding:gzip . 这意味着aspx页面会自动进行编码!

How this was happened? Is it by default?

对于js和css,没有编码,并且在 PageSpeed Insights 中它向我显示您需要压缩所有 jscss 以及高优先级部分 . How can i achieve it for my asp.net application?

1 回答

  • 1

    IIS能够为您执行gzip压缩,下面的示例进入您的web.config

    <system.webServer>
        <!-- enable gzip compression -->
        <urlCompression doStaticCompression="true" doDynamicCompression="true" dynamicCompressionBeforeCache="true" />
    </system.webServer>
    

相关问题