apache 开启zgip 压缩模式

时间:2021-11-03 18:50:42

一、Apache开启gzip压缩模式
在目录apache\conf\httpd.conf

配置 httpd.conf 文件:

#去掉
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so

#在文件的尾部添加一下代码:
#配置需要压缩的文件格式:
<ifmodule mod_deflate.c>
SetOutputFilter DEFLATE
#压缩级别,1-9,9为最高
DeflateCompressionLevel 6
#设置不对压缩的文件
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png|exe|t?gz|zip|bz2|sit|rar|pdf|mov|avi|mp3|mp4|rm)$ no-gzip dont-vary
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>