Apache页面压缩配置问题导致json数据传输时间延长

为加快js文件的下载速度,启用了apache服务器的页面压缩功能。

LoadModule deflate_module modules/mod_deflate.so

......

<IfModule deflate_module>
  DeflateCompressionLevel 9
 AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php
 AddOutputFilter DEFLATE css js
</IfModule>

发现ext-all.js等js文件的传输时间明显减少,但是查询服务器返回json数据时间大大延长,原来每次大约为100ms,现在每次大约为5.5秒。

经过追踪,发现原因是apache压缩配置,改为

<IfModule deflate_module>
  DeflateCompressionLevel 9
  #AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php
  #AddOutputFilterByType DEFLATE text/html
  #AddOutputFilterByType DEFLATE text/json application/json text/x-json application/x-json
  AddOutputFilterByType DEFLATE text/json
  AddOutputFilter DEFLATE css js
</IfModule>

这样可能牺牲部分文件的传输速度,但json数据的速度明显加快。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值