WP Hack : PHPの不要な呼び出しを少なくして高速化する!
久々のハックネタです。
ハックといっても大袈裟なものではなく、ただ余計なPHPの呼び出しを止めましょうって話です。
といっても、それほど効果があるわけではないかもしれませんが、サーバーには優しいので興味があれば試されてはいかがでしょうか?
出来るだけ少ない変更で効果がある箇所を修正したいので、まずはヘッダーと、フッターの呼び出しを少なくしましょう。
では一番簡単で、一度決めると変更されない タイトルの呼び出しを中止します。
ちなみに、ここから先は、うちで使用しているテーマ「K2]を例にしてカスタマイズしてみます。
Blogのアドレスとタイトル
<h1><a href="<?php echo get_settings('home'); ?>/"><?php bloginfo('name'); ?></a></h1>
こちらを、うちのBlogのアドレスとタイトル「orioa]に置き換えます。
<h1><a href="http://www.orioa.com/">orioa</a></h1>
テーマのスタイルシートの呼び出し。
<link rel="stylesheet" type="text/css" media="screen" href="<?php bloginfo('stylesheet_url'); ?>" />
こちらを
<link rel="stylesheet" type="text/css" media="screen" href="http://www.orioa.com/wp-content/themes/K2/style.css" />
meta情報をまとめて変更
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" /> <meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <meta name="template" content="K2 <?php k2info('version'); ?>" /> <meta name="description" content="<?php bloginfo('description'); ?>" />
これを必要なのか分からないが・・・とりあえず変更
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="generator" content="WordPress 2.3" /> <meta name="template" content="K2 svn" /> <meta name="description" content="世界で一番注目されている Blog Tool の WordPress 大好きな管理人のメモ" />
RSSのアドレスも変更
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" /> <link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" /> <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://www.orioa.com/feed/" /> <link rel="alternate" type="text/xml" title="RSS .92" href="http://www.orioa.com/feed/rss/" /> <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="http://www.orioa.com/feed/atom/" />
ヘッダーはこのぐらいにして、つぎはフッターを変更したいと思います。
<p class="footerpoweredby"><?php printf( __('Powered by %1$s and %2$s','k2_domain'), sprintf('<a href="http://wordpress.org/">%1$s<!-- %2$s--></a>', __('WordPress','k2_domain'), get_bloginfo('version') ), sprintf('<a href="http://getk2.com/" title="%1$s">K2<!-- %2$s--></a>', __('Loves you like a kitten.','k2_domain'), get_k2info('version') ) ); ?></p>
こちらを
<p class="footerpoweredby">Powered by <a href="http://wordpress.org/">WordPress</a> and <a href="http://getk2.com/" title="Loves you like a kitten.">K2</a></p>
RSSへのリンクを
<p class="footerfeedlinks"><?php printf(__('<a href="%1$s">Entries Feed</a> and <a href="%2$s">Comments Feed</a>','k2_domain'), get_bloginfo('rss2_url'), get_bloginfo('comments_rss2_url')) ?></p>
こちらに
<p class="footerfeedlinks"><a href="http://www.orioa.com/feed/">Entries Feed</a> and <a href="http://www.orioa.com/comments/feed/">Comments Feed</a></p>
と、なかなかの量ですが、体感的に変化があったような感じがします。
オリジナルテーマを使ってる方、もしくはテーマを変更する予定のない方は有効な手段ではないでしょうか?



Recent Comments