apache mod_deflate模块优化网站速度

<ifmodule mod_deflate.c>
<location />
SetOutputFilter DEFLATE

AddOutputFilterByType DEFLATE text/html text/plain text/xml
AddOutputFilter DEFLATE css #压缩css文件
AddOutputFilter DEFLATE js #压缩js文件

#BrowserMatch ^Mozilla/4 gzip-only-text/html
#BrowserMatch ^Mozilla/4\.0[678] no-gzip
#BrowserMatch \bMSIE !no-gzip !gzip-only-text/html #针对不同浏览器的配置,这里用处不大

# Don't compress images #对照片文件不进行压缩处理
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$ no-gzip dont-vary
#SetEnvIfNoCase Request_URI .(css|js)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</location>
</ifmodule>

点赞

发表回复

电子邮件地址不会被公开。必填项已用 * 标注