冰古blog » wordpress » 2005 » 03 » 27 » 加速WordPress的加载

加速WordPress的加载


当我们使用除了english的其他语言时,Wordpress转换到这种语言时通常会降低加载的速度!我看了一下其他使用了本地化方案的wordpress果然有这样的现象(就是使用了mo文件的wordpress,加载普遍在1-2sec.而没用mo文件的可以在1sec.内),下面的这个hack就可以解决这个问题了!!
我们到Here下载这个压缩包-php-gettext-1.0.3.tar.gz,解压缩后,用gettext.php和streams.php覆盖在wp-includes文件夹中的原文件即可!
另外,用$input = new CachedFileReader($mofile)代替wp-l10n.php(在 function load_textdomain 函数中)中的$input = new FileReader($mofile),也可以节省几毫秒的时间!
原文地址:
http://www.m-e-x.de/blog/index.php/archives/2005/03/01/wordpress-15-speedup/
As anyone who uses foreign language support in WordPress 1.5 may have noticed, switching to language to something other than english slows down WordPress. On my server, no request was finished in under 2 seconds.

So I had a look at the “gettext.php” and optimized it a little bit (pushes request time down to 0.1 secs again), and Danilo Segan (the author and maintainer of php-gettext) made a new release with these changes:

https://savannah.nongnu.org/projects/php-gettext/

1. Download the package
2. Replace gettext.php and streams.php (in wp-includes)

Additionally you can replace
$input = new FileReader($mofile)
in function load_textdomain (wp-l10n.php) with
$input = new CachedFileReader($mofile)
which also saves a few microseconds.

5 Responses to “加速WordPress的加载”

  1. 游戏介绍 says:

    呵呵,还好,现在博客访问量不大,不过这确实是个问题,值得好好学习学习!

  2. […] WordPress 语言包,在语言转换的过程中也会降低加载速度。不过可以做一个 Hack […]

  3. 冰古 says:

    @禅猫,这个是个hack,不过现在的wordpress应该已经做了优化,并不需要再进行修改。

  4. 禅猫 says:

    中文语言包的也可以用这个插件么?

  5. ss says:

    好的,去看看。

Leave a Reply to 游戏介绍