我发现我的服务器没有提供压缩页面。
使用这个答案 ,我将以下内容添加到了我的httpd conf文件中:
# 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
接下来,我发布了
apachectl configtest
这产生了这个错误:
无效的命令“FilterDeclare”,可能是拼错的或由未包含在服务器configuration中的模块定义的
这里是httpd -l的输出
Compiled in modules: core.c prefork.c http_core.c mod_so.c
我需要安装哪些模块才能使页面压缩工作? 我正在运行CentOS 6.6。
在CentOS中mod_filter默认是不加载的,你需要在你的httpd.conf添加或取消注释以下行:
LoadModule filter_module modules/mod_filter.so
不要忘记重新加载您的更改
service httpd graceful