facebook twitter hatena line email

Html/パフォーマンスチューニング/apache

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

ブラウザのキャッシュを利用する

  • .htaccessに追加
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf|gz|woff)$"> # 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>

参考:http://route58.org/tag/htaccess

ファイル圧縮

  • .htaccessに追加
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-opentype image/svg+xml
</IfModule>

参考:http://nelog.jp/compress-components-with-gzip

複数コネクションを同時に処理

  • vi /etc/httpd/conf/extra/xxx.conf
KeepAlive On
MaxKeepAliveRequests 20
KeepAliveTimeout 15

MaxKeepAliveRequestsは1ページあたりの読み込みファイル数+αとする

参考:http://techno-st.net/2009/04/03/keepalive-on-off.html