作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
AddOutputFilterByType在 Apache 中已弃用。
文档说使用 mod_filter 可以使用相同的功能。 .
我目前使用
AddOutputFilterByType DEFLATE text/html
最佳答案
AddOutputFilterByType
在 httpd-2.2
中存在严重限制所以它在那里被标记为已弃用。但在 httpd-2.4
此指令已移至 filter_module
,已更正且未弃用。
在 apache 2.2 中,您应该启用 filter_module
和 deflate_module
并使用:
# Declare a "gzip" filter, it should run after all internal filters like PHP or SSI
FilterDeclare gzip CONTENT_SET
# "gzip" filter can change "Content-Length", can not be used with range requests
FilterProtocol gzip change=yes;byteranges=no
# Enable "gzip" filter if "Content-Type" contains "text/html", "text/css" etc.
FilterProvider gzip DEFLATE resp=Content-Type $text/html
FilterProvider gzip DEFLATE resp=Content-Type $text/css
FilterProvider gzip DEFLATE resp=Content-Type $text/javascript
FilterProvider gzip DEFLATE resp=Content-Type $application/javascript
FilterProvider gzip DEFLATE resp=Content-Type $application/x-javascript
# Add "gzip" filter to the chain of filters
FilterChain gzip
deflate_module
只会向声明支持
gzip
的浏览器提供压缩内容请求头中的编码。
关于Apache AddOutputFilterByType 已弃用。如何使用 mod_filter 重写?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5230202/
我是一名优秀的程序员,十分优秀!