网页前端优化-apache篇

以下配置内容放在 httpd.conf 配置文件最后即可,全局有效.

1.设置静态文件的有效期

ExpiresActive On

<FilesMatch "\.(gif|jpg|png|js|css)$">
ExpiresDefault "access plus 10 years"
</FilesMatch>

参考: http://blog.haohtml.com/archives/3728

2.启用gzip压缩

DeflateBufferSize 8096
DeflateCompressionLevel 1
DeflateMemLevel 9
DeflateWindowSize 15

DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
DeflateFilterNote ratio
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
CustomLog logs/deflate.log deflate

<Location />
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css application/x-javascript text/plain text/xml
</Location>

参考: http://blog.haohtml.com/archives/3327,注意上面的日志路径要正确


3.配置ETags减少Web应用带宽和负载

FileETag none

参考: http://blog.haohtml.com/archives/3731

4.使用不同的域名提高网页效率-优化网站性能(yslow)

参考: http://blog.haohtml.com/archives/3739

你可能感兴趣的:(JavaScript,apache,css,Blog,Access)