开启Apache的GZIP压缩功能

在Apache2之后的版本,GZIP压缩模块名不叫gzip,而叫mod_deflate

1) 找到apache的配置文件httpd.conf,找到下面两行,将前面的 # 去掉。

  1. LoadModule headers_module modules/mod_headers.so
  2. LoadModule deflate_module modules/mod_deflate.so

2) 增加一个节点

<ifmodule mod_deflate.c>

DeflateCompressionLevel 6

AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php

AddOutputFilter DEFLATE css js

</ifmodule>

参数说明:DeflateCompressionLevel 压缩等级,值1-9,

3) 保存退出。

4) 重启Apache服务。

微信扫一扫 或 点击链接联系我

《开启Apache的GZIP压缩功能》有8条评论

发表评论