当前位置首页 > IIS知识

IISaspnetHTTP压缩与Ajax

阅读次数:371 次  来源:admin  发布时间:

最近在做IIS ASPNET的项目,对首页访问速度要求比较高。

通过配置AppPool可以有效提高IIS的响应速度。

启用IIS的HTTP压缩后,对于ASPX的程序处理和Ajax方式调用产生了问题。

IIS的HTTP压缩配置比较简单不能支持比较灵获得配置。

我搜 找到了 blowery.Web.HttpCompress(在线文档) 这个在性能上评价还不错。

配置


Web.config
<configSections>
<sectionGroup name="blowery.web">
<section name="httpCompress" type="blowery.Web.HttpCompress.SectionHandler, blowery.Web.HttpCompress"/>
</sectionGroup>
</configSections>

lowery.we


<blowery.web>
<httpCompress preferredAlgorithm="gzip" compressionLevel="high">
<excludedMimeTypes>
<add type="image/jpeg"/>
<add type="image/gif"/>

lt;add type="text/plain"/> <!--解决Ajax回调不支持压缩格式的问题-->


</excludedMimeTypes>
<excludedPaths>
<add path="NoCompress.aspx"/>
</excludedPaths>
</httpCompress>
</blowery.web>

excludedMimeTypes 包含的在此的Mime类型将不被压缩

excludedPaths 包含的在此的aspx将不被压缩

注意源代码中有一处bug,在处理excludePaths时不起作用

tring realPath = ""

try

{

logger.Debug(app.Request.ApplicationPath)

realPath = app.Request.Path.Remove(0, app.Request.ApplicationPath.Length)

}

catch (Exception ex)

{

logger.Debug(ex.Message)

realPath = "/"

}

经测试 一个35K的页面,可以控制在10~15k大小,这会大大加快传输的速度。

总体效果不错。
上一篇:CentOS7下使用Certbot+Nginx搭建Https环境
下一篇:Window2003中的修改事项:IIS服务器数据库不能写入的原因分析及解决办法.