WP Hack : PHPの不要な呼び出しを少なくして高速化する!

久々のハックネタです。
ハックといっても大袈裟なものではなく、ただ余計なPHPの呼び出しを止めましょうって話です。
といっても、それほど効果があるわけではないかもしれませんが、サーバーには優しいので興味があれば試されてはいかがでしょうか?

出来るだけ少ない変更で効果がある箇所を修正したいので、まずはヘッダーと、フッターの呼び出しを少なくしましょう。

では一番簡単で、一度決めると変更されない タイトルの呼び出しを中止します。
ちなみに、ここから先は、うちで使用しているテーマ「]を例にしてカスタマイズしてみます。

Blogのアドレスとタイトル

CODE:
  1. <h1><a href="<?php echo get_settings('home'); ?>/"><?php bloginfo('name'); ?></a></h1>

こちらを、うちのBlogのアドレスとタイトル「orioa]に置き換えます。

CODE:
  1. <h1><a href="http://www.orioa.com/">orioa</a></h1>


テーマのスタイルシートの呼び出し。

CODE:
  1. <link rel="stylesheet" type="text/css" media="screen" href="<?php bloginfo('stylesheet_url'); ?>" />

こちらを

CODE:
  1. <link rel="stylesheet" type="text/css" media="screen" href="http://www.orioa.com/wp-content/themes//style.css" />

meta情報をまとめて変更

CODE:
  1. <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
  2.     <meta name="generator" content=" <?php bloginfo('version'); ?>" />
  3.     <meta name="template" content=" <?php k2info('version'); ?>" />
  4.     <meta name="description" content="<?php bloginfo('description'); ?>" />

これを必要なのか分からないが・・・とりあえず変更

CODE:
  1. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  2.     <meta name="generator" content=" 2.3" />
  3.     <meta name="template" content=" svn" />
  4.     <meta name="description" content="世界で一番注目されている Blog Tool の 大好きな管理人のメモ" />

RSSのアドレスも変更

CODE:
  1. <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
  2.     <link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
  3.     <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />

CODE:
  1. <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://www.orioa.com/feed/" />
  2.     <link rel="alternate" type="text/xml" title="RSS .92" href="http://www.orioa.com/feed/rss/" />
  3.     <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="http://www.orioa.com/feed/atom/" />

ヘッダーはこのぐらいにして、つぎはフッターを変更したいと思います。

CODE:
  1. <p class="footerpoweredby"><?php printf( __('Powered by %1$s and %2$s','k2_domain'),
  2.         sprintf('<a href="http://.org/">%1$s<!-- %2$s--></a>',
  3.             __('','k2_domain'),
  4.             get_bloginfo('version')
  5.         ),
  6.         sprintf('<a href="http://getk2.com/" title="%1$s"><!-- %2$s--></a>',
  7.             __('Loves you like a kitten.','k2_domain'),
  8.             get_k2info('version')
  9.         )
  10.     ); ?></p>

こちらを

CODE:
  1. <p class="footerpoweredby">Powered by <a href="http://.org/"></a> and <a href="http://getk2.com/" title="Loves you like a kitten."></a></p>

RSSへのリンクを

CODE:
  1. <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>

こちらに

CODE:
  1. <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>

と、なかなかの量ですが、体感的に変化があったような感じがします。

オリジナルテーマを使ってる方、もしくはテーマを変更する予定のない方は有効な手段ではないでしょうか?

Related posts

0 Responses to “WP Hack : PHPの不要な呼び出しを少なくして高速化する!”


  1. No Comments

Leave a Reply





T1
Pigments
Love
Loopy Red
Facebooked
Ranting Daily
Pink for October
Saur