Html/パフォーマンスチューニング
提供: 初心者エンジニアの簡易メモ
解析ツール
GTMetrix http://gtmetrix.com/
Google PageSpeed Insights https://developers.google.com/speed/pagespeed/insights/?hl=ja
ブラウザのキャッシュを利用する
- .htaccessに追加
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf|gz)$"> # 24weeks Header set Cache-Control "max-age=14515200, public" </FilesMatch> <FilesMatch "\.(xml|txt)$"> # 2DAYS Header set Cache-Control "max-age=172800, public, must-revalidate" </FilesMatch> <FilesMatch "\.(html|htm)$"> # 2HOURS Header set Cache-Control "max-age=7200, must-revalidate" </FilesMatch>
<source>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf|gz)$"> # 24weeks Header set Cache-Control "max-age=14515200, public" </FilesMatch> <FilesMatch "\.(xml|txt)$"> # 2DAYS Header set Cache-Control "max-age=172800, public, must-revalidate" </FilesMatch> <FilesMatch "\.(html|htm)$"> # 2HOURS Header set Cache-Control "max-age=7200, must-revalidate" </FilesMatch>
</source>
参考:http://route58.org/tag/htaccess
ファイル圧縮
- .htaccessに追加
AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript
参考:http://nelog.jp/compress-components-with-gzip
複数コネクションを同時に処理
- vi /etc/httpd/conf/extra/xxx.conf
KeepAlive On MaxKeepAliveRequests 20 KeepAliveTimeout 15
MaxKeepAliveRequestsは1ページあたりの読み込みファイル数+αとする