2013-03-19 47 views
2

我有这个在我的.htaccess文件:为什么我的Markdown文件没有被压缩?

# gzip compression 
<ifmodule mod_deflate.c> 
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript application/json 
</ifmodule> 

这可以确保给定的内容类型gzip压缩。

现场演示:http://ecmazing.com/js/index.js(打开“网络”面板中的浏览器的开发工具,并期待在响应头)

enter image description here

但我的降价文件被gzip压缩。

现场演示:http://ecmazing.com/data.md

enter image description here

正如你可以看到文件的内容类型为text/plain是在内容类型的我.htaccess文件列表。那么,为什么不应用GZIP?

+1

结尾'.md'的文件与您在AddOutputFilterByType之后列出的Mime类型之一有关... ...?你尝试过'AddOutputFilter deflate md'吗? – CBroe 2013-03-19 12:39:39

+0

@CBroe服务器以“Content-Type text/plain”响应。这不是说是吗? – 2013-03-19 12:41:07

+0

@CBroe我添加了'AddOutputFilter deflate md',它现在可以工作:)。你能解释为什么吗? – 2013-03-19 12:43:39

回答

2

我猜你的降价文件没有主动通过AddType指令指定的内容类型text/plain - 这样的服务器可能会发送内容类型的默认值,但AddOutputFilterByType不承认这些文件为那内容类型自动。

http://httpd.apache.org/docs/2.2/en/mod/core.html#addoutputfilterbytype证实,他说:

“启用与AddOutputFilterByType过滤器可以部分或完全失效的情况。例如,如果MIME类型不能确定,并回落到DefaultType的设置,甚至当DefaultType是一样的,不应用过滤器“

所以使用AddOutputFilter deflate md代替 - 或尝试与之为伍.md内容类型明确使用AddType text/plain md

+0

是的。我已经结束了这个'AddType'text/plain; charset = UTF-8'md'。我也添加了字符集,因为我的MD包含非ASCII字符。 – 2013-03-19 13:20:29

相关问题