针对windows版本的apache2.2,开启方法如下:
第一步:
找到apache的配置文件httpd.conf,找到下面两行,将前面的 # 去掉.
[toggle state=”closed” title=”点我查看”]
- LoadModule deflate_module modules/mod_deflate.so
- LoadModule expires_module modules/mod_expires.so
[/toggle]
保存配置后重启apache服务
第二步:
打开网站的 .htaccess 文件,将下面代码拷贝进去:
[toggle state=”closed” title=”点我查看”]
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault “access plus 12 month”
ExpiresByType text/html “access plus 12 months”
ExpiresByType text/css “access plus 12 months”
ExpiresByType image/gif “access plus 12 months”
ExpiresByType image/jpeg “access plus 12 months”
ExpiresByType image/jpg “access plus 12 months”
ExpiresByType image/png “access plus 12 months”
EXpiresByType application/x-shockwave-flash “access plus 12 months”
EXpiresByType application/x-javascript”access plus 12 months”
ExpiresByType video/x-flv “access plus 12 months”
</IfModule>
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css image/gif image/jpeg image/png application/x-javascript
</IfModule>
[/toggle]
效果如下:
附上检测地址:
http://gzip.zzbaike.com/