您的位置:首页 > 运维架构 > Apache

关于apache服务器支持断点续传的一点理解

2013-11-11 09:50 295 查看
默认情况下,当下载文件的时候会开启gzip和chunk。

但是chunk没有Content-Length,而范围响应 206 Partial Content又需要Content-Length,

这样的话要让apache同时支持gzip和断点续传就麻烦了。

解决方案是:

遇到text/plain类型的就启用gzip(apache同时会自动启用chunk)

遇到二进制类型的就不启用gzip(apache同时也就不会启用chunk了)

配置文件修改:

LoadModule deflate_module modules/mod_deflate.so

LoadModule headers_module modules/mod_headers.so

#遇到MIME为text类型的就启用gzip

#遇到其他MIME类型的就不启用gzip

<IfModule mod_deflate.c>

#gzip压缩

DeflateCompressionLevel 9

#SetOutputFilter DEFLATE

AddOutputFilterByType DEFLATE text/html text/plain

#DeflateFilterNote Input instream

#DeflateFilterNote Output outstream

#DeflateFilterNote Ratio ratio

#LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate

CustomLog logs/deflate_log.log deflate

</IfModule>

#开启Accept-Ranges响应头

<IfModule mod_headers.c>

Header set Accept-Ranges bytes

</IfModule>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐