1.打开 apache 的 httpd.conf 配置文件, 删除下面的 #
LoadModule deflate_module modules/mod_deflate.so LoadModule headers_module modules/mod_headers.so LoadModule filter_module modules/mod_filter.so
2.在 Apache 配置文件 httpd.conf 的最后添加:
<IfModule deflate_module> SetOutputFilter DEFLATE SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary SetEnvIfNoCase Request_URI .(?:pdf|doc|avi|mov|mp3|rm)$ no-gzip dont-vary AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css AddOutputFilterByType DEFLATE application/x-javascript </IfModule>
如何查看页面是否开启了gzip压缩 : https://www.cnblogs.com/rslai/p/7929130.html