首页 > apache开启gzip压缩与expires

apache开启gzip压缩与expires

2011-11-15   hisenKing

打开httpd.conf查找下面两行,去掉前面的#
#LoadModule deflate_module modules/mod_deflate.so
#LoadModule expires_module modules/mod_expires.so

打开网站的 .htaccess 文件,将下面代码拷贝进去:


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"

SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css image/gif image/jpeg image/png application/x-javascript

开启前响应头与开启后响应头得区别

ysolow开启前与开启后的区别

 

其中ubuntu下apache默认是没有开启expires的;

#a2enmod expires 开启expires模块,并重启apache即可

好久没更新了,需要除除草