<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>阅微堂 &#187; 优化</title>
	<atom:link href="http://zhiqiang.org/blog/tag/%e4%bc%98%e5%8c%96/feed" rel="self" type="application/rss+xml" />
	<link>http://zhiqiang.org/blog</link>
	<description>zhiqiang&#039;s personal blog</description>
	<lastBuildDate>Wed, 08 Sep 2010 04:07:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>WordPress全站静态化</title>
		<link>http://zhiqiang.org/blog/it/the-whole-point-of-static-wordpress.html</link>
		<comments>http://zhiqiang.org/blog/it/the-whole-point-of-static-wordpress.html#comments</comments>
		<pubDate>Thu, 15 Mar 2007 06:04:27 +0000</pubDate>
		<dc:creator>zhiqiang</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[优化]]></category>
		<category><![CDATA[静态化]]></category>

		<guid isPermaLink="false">http://zhiqiang.org/blog/537.html</guid>
		<description><![CDATA[继上次把主页静态化后，现在本站所有文章都已经是静态的html页面，跟MT系统差不多，当有新文章或者新留言，相关的html文件在后台自动更新。比如这篇文章http://zhiqiang.org/blog/536.html是一个服务器上真正的文件，而以前它被rewrite到http://zhiqiang.org/blog/index.php?p=536，HTML页面的创立时间(服务器端)可见页脚：
&#160;
静态化一个好处是，降低数据库查询和CPU占用率，host HTML所用资源...]]></description>
			<content:encoded><![CDATA[<p>继上次把<a href="http://zhiqiang.org/blog/420.html" target="_blank">主页静态化</a>后，现在本站所有文章都已经是静态的html页面，跟MT系统差不多，当有新文章或者新留言，相关的html文件在后台自动更新。比如这篇文章<a href="http://zhiqiang.org/blog/536.html">http://zhiqiang.org/blog/536.html</a>是一个服务器上真正的文件，而以前它被rewrite到<a href="http://zhiqiang.org/blog/index.php?p=536">http://zhiqiang.org/blog/index.php?p=536</a>，HTML页面的创立时间(服务器端)可见页脚：</p>
<p align="center">&nbsp;<a title="footer_time" href="http://www.flickr.com/photos/51234757@N00/421789940/"><img alt="footer_time" src="http://static.flickr.com/158/421789940_d1d5b5fc38.jpg" border="0"></a></p>
<p>静态化一个好处是，降低数据库查询和CPU占用率，host HTML所用资源极少。不过我的主要目的是减少用户访问时的页面载入时间。我很喜欢现在的<a href="http://www.douban.com/" target="_blank">douban</a>，页面基本上即点即开——可能是因为服务器质量和位置比较好。</p>
<p>不知道是不是开了GZip传输的原因，现在页面打开时，需要几秒钟等待，然后页面一下子全开。与我想象中的页面慢慢显示，可以边显示边浏览不一样。另外在FireFox下，有时候背景图片比页面内容晚出现，页面载入完全前特别难看，不知道怎么解决。</p>
<p>实现方法是通过<a href="http://ud03.kinoko.name/Archive/545/" target="_blank">WP-Write HTML</a>这个插件来实现的，不过我hack和删除了90%代码，因为我不需要那么多功能，而且本blog的URL结构比较简单。</p>
<p>静态页面一般不支持COOKIE，不过还有javascript可以用：</p>
<blockquote><p><span style="color: #008000">// Retrieve the value of the cookie with the specified name.</span><br /><span style="color: #0000ff">var</span> aCookie = <span style="color: #0000ff">document</span>.cookie.split("<span style="color: #8b0000">;</span>");<br /><span style="color: #0000ff">function</span> GetCookie(sName, id)<br />{<br />&nbsp;&nbsp;&nbsp; <span style="color: #008000">// cookies are separated by semicolons</span><br />	<span style="color: #0000ff">var</span> something = <span style="color: #0000ff">document</span>.getElementById(id);<br />	<span style="color: #0000ff">if</span>(!something) <span style="color: #0000ff">return</span> 0;<br />&nbsp;&nbsp;&nbsp; 	<span style="color: #0000ff">for</span> (<span style="color: #0000ff">var</span> i=0; i &lt; aCookie.<span style="color: #0000ff">length</span>; i++)<br />&nbsp;&nbsp;&nbsp; 	{<br /><span style="color: #008000">// a name alue pair (a crumb) is separated by an equal sign</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 	<span style="color: #0000ff">var</span> aCrumb = aCookie[i].split("<span style="color: #8b0000">=</span>");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 	<span style="color: #0000ff">if</span> (sName == aCrumb[0]){<br />			something.value=<span style="color: #0000ff">unescape</span>(aCrumb[1]);<br />			<span style="color: #0000ff">return</span> 1;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 	}<br />&nbsp;&nbsp;&nbsp; 	}<br /><span style="color: #008000">// a cookie with the requested name does not exist</span><br />&nbsp;&nbsp; 	<span style="color: #0000ff">return</span> 0;<br />}</p>
</blockquote>
<p>这次系统升级是看到<a href="http://www.storyday.com/web-tech/576/cache-machanism-of-mysite" target="_blank">关于本站缓存机制的说明</a>这篇文章后做出的，不过所用方法不同。另外还有一篇<a href="http://blog.znsunimage.com/2007/03/11/504" target="_blank">WordPress的优化手册</a>也值得一看，特别是最后的image meta部分。</p>
<p>另注：Firefox的<a href="http://fasterfox.mozdev.org/" target="_blank">fasterfox</a>插件能在右下角显示网页载入所需时间。</p>
<p></p>
<div><h2>相关文章</h2><ul><li><a href="http://zhiqiang.org/blog/it/wordpress-accelerate-the-pace-of-pages-printed-in-the-generation-and.html">加快WordPress的页面生成和载入速度</a> <small>前一阵，此blog的页面打开速度慢的要命，我每次打开都需要大约10秒钟的时间。而通过Google Analytics的数据看到，70%+用户在这个blog的停留时间还不到十...</small></li><li><a href="http://zhiqiang.org/blog/it/a-new-static-wordpress-plug-cos-of-cache-html.html">一个新的WordPress静态化插件cos-html-cache</a> <small>阅微堂是国内WordPress用户较早实现静态化的blog之一。之前，本站所用的是修改WP-Write HTML插件实现的静态化，不过这个插件已经没人维护，我也没时间...</small></li><li><a href="http://zhiqiang.org/blog/it/blog-fast-download-speeds-to-be-faster-and-the-speed-of-blog.html">blog下载速度多快才算快和blog速度优化</a> <small>很多人有一个大致的感觉，某blog很慢，或者有点慢，但是似乎还过得去，而没有一个量化的指标。其实对于FireFox浏览器，使fastfox插件，可以在右下方...</small></li><li><a href="http://zhiqiang.org/blog/it/wordpress-create-the-most-efficient-of-all-stations-browsing.html">打造最快捷的wordpress的全站浏览方式</a> <small>我们有很多种方式浏览全站文章，主页面往前翻页，通过察看分类和按日期存档察看，或者通过搜索查找自己敢兴趣的东西。这些方法的缺陷就是太慢...</small></li><li><a href="http://zhiqiang.org/blog/it/wordpress-21-solution-can-not-remove-the-article-upgrade-to-213.html">WordPress 2.1无法删除文章解决方法 &amp; 升级到2.1.3</a> <small>如果你在升级WordPress到2.1之后遇到以下情况：  无法删除文章(post)在文章列表的"Edit"链接旁边，看不到该有的"Delete"链接。在Edit文章界面，点击"Delete thi...</small></li><li><a href="http://zhiqiang.org/blog/it/how-delete-wordpress-category-base.html">如何去掉category permalink base？</a> <small>一般而言，WordPress的blog的分类category-name地址是http://yoursite/category/category_name，其中/category/称为分类的permalink base，它可以在后台设定为任何字符串。
...</small></li><li><a href="http://zhiqiang.org/blog/it/wordspew-plug-litter-message-solution.html">wordspew插件的垃圾留言的解决办法</a> <small>wordspew插件可以给Blog添加一个实时的ajax聊天窗口，也可以用来当作一个简单留言板，具体效果可见本blog左侧栏的在线聊天模块。本来一直用得挺好的...</small></li><li><a href="http://zhiqiang.org/blog/it/wordpress-the-revised-calendar-own-style.html">修改wordpress的自带日历式样</a> <small>wordpress自带了一个日历函数get_calendar()，可以显示每天各发了哪些文章（把鼠标移到日期上即可看到），是个很实用的函数。可是它原来的式样太丑了...</small></li><li><a href="http://zhiqiang.org/blog/it/reading-church-wordpress-plug-in-system-architecture-use.html">阅微堂系统架构 &#038; WordPress插件使用情况</a> <small>本系统使用了以下插件：

	Ajax Comments-Reply: 可以在迴響之後跟隨回覆，使用Ajax無刷新。经过一些修改后，实现本系统的MSN Spaces风格的页面ajax显示和...</small></li><li><a href="http://zhiqiang.org/blog/science/computer-science/move-blogbus-data-to-wordpress.html">BlogBus搬家文件转WordPress导入文件</a> <small>  最近给某blog做了一次搬家，从Sina转到WordPress独立博客，网上已经有很多工具和方法，但可用而且耗用的不多，总是有一些乱七八糟的问题。这里说一...</small></li></ul></div>    <p></p>
    <hr noshade style="margin:0;height:1px" />
    <p>&copy; zhiqiang for <a href="http://zhiqiang.org/blog">阅微堂</a>, 2007. | <a href="http://zhiqiang.org/blog/it/the-whole-point-of-static-wordpress.html">&#38142;&#25509;</a> | <a href="http://zhiqiang.org/blog/it/the-whole-point-of-static-wordpress.html#comments">42 &#26465;&#35780;&#35770;</a></p>]]></content:encoded>
			<wfw:commentRss>http://zhiqiang.org/blog/it/the-whole-point-of-static-wordpress.html/feed</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>blog下载速度多快才算快和blog速度优化</title>
		<link>http://zhiqiang.org/blog/it/blog-fast-download-speeds-to-be-faster-and-the-speed-of-blog.html</link>
		<comments>http://zhiqiang.org/blog/it/blog-fast-download-speeds-to-be-faster-and-the-speed-of-blog.html#comments</comments>
		<pubDate>Sat, 02 Sep 2006 04:39:09 +0000</pubDate>
		<dc:creator>zhiqiang</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[优化]]></category>
		<category><![CDATA[速度]]></category>

		<guid isPermaLink="false">http://zhiqiang.org/blog/429.html</guid>
		<description><![CDATA[很多人有一个大致的感觉，某blog很慢，或者有点慢，但是似乎还过得去，而没有一个量化的指标。其实对于FireFox浏览器，使fastfox插件，可以在右下方显示页面的载入时间。注意测试时将fastfox插件选项调为默认，既不进行任何优化，因为我们必须假设大多数用户没有安装此插件。
对于一个网页的显示速度，有两个方面可以衡量，一个是内容首现速度，另一个是页面完成速度...]]></description>
			<content:encoded><![CDATA[<p>很多人有一个大致的感觉，某blog很慢，或者有点慢，但是似乎还过得去，而没有一个量化的指标。其实对于FireFox浏览器，使<a rel="fastfox插件安装地址" target="_blank" href="https://addons.mozilla.org/firefox/1269/">fastfox</a>插件，可以在右下方显示页面的载入时间。注意测试时将fastfox插件选项调为默认，既不进行任何优化，因为我们必须假设大多数用户没有安装此插件。</p>
<p>对于一个网页的显示速度，有两个方面可以衡量，一个是内容首现速度，另一个是页面完成速度。比如说臃肿的<a href="http://news.sina.com.cn/">sina新闻</a>首页，2秒就可以开始浏览新闻了，但是20秒之后才会把页面显示完全。由于游览器一般都是边下载便显示内容，所以我认为前者更为重要一些。</p>
<p>另外，对于访问者而言，显示速度还分为两种，首次访问速度和页面跳转速度。对于一些页面文件和图片比较多的网页，首次访问速度非常慢，但是进去之后在网页之间的跳转就快得多了，因为浏览器会缓存很多文件。</p>
<p>在网上看到一篇文章——<a target="_blank" href="http://www.marketingman.net/wminfo/4130.htm">网站设计参考：网站下载速度多快才算快</a>：</p>
<blockquote><p>网站下载速度的快慢，在不同时期，不同的网络环境条件下，其绝对指标会有很大差别，现在1秒属于下载快的水平，但再过2年之后，说不定用户已经对1秒钟这样长的下载时间无法忍受了。</p>
<p>雅虎网站创始人的杨致远曾说过，为打开一个网页，网民最大的忍受时间为8秒，如果超出了这个时间，用户就会走掉。</p></blockquote>
<p>我自己这个blog在我这里的连接速度大概是首次访问5到7秒钟(通过CTR+F5强制刷新得到)，页面间的跳转则需要大约2到4秒钟，根据所显示的页面长度略有差别。按照上面的标准，已经是非常慢的了。</p>
<p>但是，我现在的网络状况下，我所上的大部分网站的速度都无法达到上面文章里提到的速度。就拿blog而言，我现在访问的很多blog的首次访问速度都超过了上面所说的8秒的临界值。那种等上10秒钟还没有显示一个字的blog是非常恐怖的，我基本上是强制刷新重新载入或者直接关掉。</p>
<p>所以，一些优化是很必要的。在我<a href="http://zhiqiang.org/blog/420.html">加快WordPress的页面生成和载入速度</a>之前，我的blog也是10秒一族，但现在快了一倍以上，至少在我这里（北京教育网）是这样的。后来看到<a href="http://my.donews.com/htmlor/2006/08/03/serving_javascript_fast_chinese/">flickr对javascript干的好事</a>这篇文章，这里讲了更多的关于php和javascript的优化技巧，其中就有合并js文档和缓存页面等。我想某些站长应该考虑一下其中的方法。</p>
<p>一个更直接，而且不需要任何技术的方法是尽量不用需要下载js和css的插件（比如很多人喜欢安装coolplayer这类播放器插件，但对于一般人来说，根本不需要这么强大的播放器定制功能，一段简单的代码足够用了），以及使用图片较少的模版。把有的站点的源代码当下来一看，光js文件就10多个，这是非常恐怖的。</p>
<div><h2>相关文章</h2><ul><li><a href="http://zhiqiang.org/blog/it/wordpress-accelerate-the-pace-of-pages-printed-in-the-generation-and.html">加快WordPress的页面生成和载入速度</a> <small>前一阵，此blog的页面打开速度慢的要命，我每次打开都需要大约10秒钟的时间。而通过Google Analytics的数据看到，70%+用户在这个blog的停留时间还不到十...</small></li><li><a href="http://zhiqiang.org/blog/it/the-whole-point-of-static-wordpress.html">WordPress全站静态化</a> <small>继上次把主页静态化后，现在本站所有文章都已经是静态的html页面，跟MT系统差不多，当有新文章或者新留言，相关的html文件在后台自动更新。比如这...</small></li><li><a href="http://zhiqiang.org/blog/it/wordpress-21-solution-can-not-remove-the-article-upgrade-to-213.html">WordPress 2.1无法删除文章解决方法 &amp; 升级到2.1.3</a> <small>如果你在升级WordPress到2.1之后遇到以下情况：  无法删除文章(post)在文章列表的"Edit"链接旁边，看不到该有的"Delete"链接。在Edit文章界面，点击"Delete thi...</small></li><li><a href="http://zhiqiang.org/blog/it/wordspew-plug-litter-message-solution.html">wordspew插件的垃圾留言的解决办法</a> <small>wordspew插件可以给Blog添加一个实时的ajax聊天窗口，也可以用来当作一个简单留言板，具体效果可见本blog左侧栏的在线聊天模块。本来一直用得挺好的...</small></li><li><a href="http://zhiqiang.org/blog/it/bbpress-installation-problems-and-several-plug-ins.html">bbPress的安装问题和几个插件</a> <small>演示地址：http://zhiqiang.org/bbs/.

bbPress是一个微型论坛程序，官方主页 http://bbpress.org，与WordPress是同一批人开发维护的。主要特点是简洁，且与WordPress...</small></li><li><a href="http://zhiqiang.org/blog/it/my-experiences-and-views-blog.html">我的Blog经历和一些看法</a> <small>我是从去年3月开始接触Blog的，最开始注册在MSN Spaces上面，中途见异思迁了一次，搬到sina blog上去了，不过后来还是搬回去了。到今年4月，觉得MSN Space...</small></li><li><a href="http://zhiqiang.org/blog/it/wordpress-the-revised-calendar-own-style.html">修改wordpress的自带日历式样</a> <small>wordpress自带了一个日历函数get_calendar()，可以显示每天各发了哪些文章（把鼠标移到日期上即可看到），是个很实用的函数。可是它原来的式样太丑了...</small></li><li><a href="http://zhiqiang.org/blog/it/reading-church-wordpress-plug-in-system-architecture-use.html">阅微堂系统架构 &#038; WordPress插件使用情况</a> <small>本系统使用了以下插件：

	Ajax Comments-Reply: 可以在迴響之後跟隨回覆，使用Ajax無刷新。经过一些修改后，实现本系统的MSN Spaces风格的页面ajax显示和...</small></li><li><a href="http://zhiqiang.org/blog/it/how-delete-wordpress-category-base.html">如何去掉category permalink base？</a> <small>一般而言，WordPress的blog的分类category-name地址是http://yoursite/category/category_name，其中/category/称为分类的permalink base，它可以在后台设定为任何字符串。
...</small></li><li><a href="http://zhiqiang.org/blog/it/wordpress-create-the-most-efficient-of-all-stations-browsing.html">打造最快捷的wordpress的全站浏览方式</a> <small>我们有很多种方式浏览全站文章，主页面往前翻页，通过察看分类和按日期存档察看，或者通过搜索查找自己敢兴趣的东西。这些方法的缺陷就是太慢...</small></li></ul></div>    <p></p>
    <hr noshade style="margin:0;height:1px" />
    <p>&copy; zhiqiang for <a href="http://zhiqiang.org/blog">阅微堂</a>, 2006. | <a href="http://zhiqiang.org/blog/it/blog-fast-download-speeds-to-be-faster-and-the-speed-of-blog.html">&#38142;&#25509;</a> | <a href="http://zhiqiang.org/blog/it/blog-fast-download-speeds-to-be-faster-and-the-speed-of-blog.html#comments">5 &#26465;&#35780;&#35770;</a></p>]]></content:encoded>
			<wfw:commentRss>http://zhiqiang.org/blog/it/blog-fast-download-speeds-to-be-faster-and-the-speed-of-blog.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>加快WordPress的页面生成和载入速度</title>
		<link>http://zhiqiang.org/blog/it/wordpress-accelerate-the-pace-of-pages-printed-in-the-generation-and.html</link>
		<comments>http://zhiqiang.org/blog/it/wordpress-accelerate-the-pace-of-pages-printed-in-the-generation-and.html#comments</comments>
		<pubDate>Sat, 26 Aug 2006 05:31:06 +0000</pubDate>
		<dc:creator>zhiqiang</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP-Cache 2.0]]></category>
		<category><![CDATA[优化]]></category>
		<category><![CDATA[加速]]></category>
		<category><![CDATA[静态化]]></category>

		<guid isPermaLink="false">http://zhiqiang.org/blog/420.html</guid>
		<description><![CDATA[前一阵，此blog的页面打开速度慢的要命，我每次打开都需要大约10秒钟的时间。而通过Google Analytics的数据看到，70%+用户在这个blog的停留时间还不到十秒:(。所以我决定加速一下我的blog，后来看起来似乎有些效果。下面是我用的一些方法，希望对后来人有些用处。
安装WP-Cache 2.0
WP-Cache 2.0可以将页面缓存，在短时间内(默认为1个小时，可以在后台设置)的再次浏览，将直接发送...]]></description>
			<content:encoded><![CDATA[<p>前一阵，此blog的页面打开速度慢的要命，我每次打开都需要大约10秒钟的时间。而通过Google Analytics的数据看到，70%+用户在这个blog的停留时间还不到十秒:(。所以我决定加速一下我的blog，后来看起来似乎有些效果。下面是我用的一些方法，希望对后来人有些用处。</p>
<h3><font size="3">安装</font><a href="http://mnm.uib.es/gallir/wp-cache-2/">WP-Cache 2.0</a></h3>
<p>WP-Cache 2.0可以将页面缓存，在短时间内(默认为1个小时，可以在后台设置)的再次浏览，将直接发送缓存的页面，相当于将WordPress给静态化了。</p>
<p>好处是显然的。而且这个版本的WP-Cache 2.0在缓存的时候根据页面URL+Cookie进行缓存的，所以它不会影响COOKIE的使用。注意，WP-Cache 2.0只读取Cookie中的email地址，然后根据email地址判定是否属于同一个用户。由于大多数人都没有留下Email，所以我修改成根据Cookie中的用户名来判断，将插件目录下的wp-cache-phase1.php的第67行改成：</p>
<blockquote>
<p align="left">//if (preg_match("/^wordpress|^comment_author_email_/", $key)) {<br />
if (preg_match("/^wordpress|^comment_author_/", $key)) {</p></blockquote>
<p align="left">由于大部浏览者的cookie都是空的，所以这个插件会加快这大部分的浏览速度。另外，这个插件还会侦测文章更新，实时更新缓存等。</p>
<p align="left">但是缺点也是显然的。首先，在页面还没有生成的时候，就进行COOKIE的读取和交换，将降低速度，某种程度上来说，它使得头次浏览的速度更慢。再者，这个插件在运行的时候，还是得先把其他插件初始化，所以它只是减少了页面生成的函数调用的时间。</p>
<p align="left"><strong>效果：不明显。</strong>事实上，这个插件主要是用来降低系统CPU占用量的，对页面载入速度影响有限。</p>
<h3>改善插件</h3>
<p>我并没有安装太多插件，而且都是些小型的插件，从来不装像UTW那样的巨无霸插件。但是我还是把那些非插件必须的文件(大部分是我修改插件的时候新加的)都移出插件目录。以免WP错把它们当成插件文件进行初始化处理。</p>
<p><strong>效果不明</strong>。因为经过处理的文件不多也不大，想必影响有限。</p>
<h3>页面静态化</h3>
<p>一个不变的事实是：html页面永远要比php页面快的多，而且几乎不占用CPU资源。所以将页面静态化是一个好主意。但将所有页面静态化，没有这个必要。所以我选择了将blog主页进行静态化处理——各位如果不信的话，直接页面刷新，然后看一下右边的随机文章变了没有:)。</p>
<p>我同学告诉我页面静态化有很多种方法，但我决定采用最土的一种方法：</p>
<p>首先，在根目录下建立一个cron.sh文件，里面的内容是：</p>
<blockquote><p>wget -O /home/aaaa/zhiqiang.org/blog/index.html http://zhiqiang.org/blog/index.php</p></blockquote>
<p>上面的/home/aaaa是我的根目录，其中aaaa是用户名。再使用Fterm SSH登录远程主机，输入</p>
<blockquote><p>crontab -e</p></blockquote>
<p>在出来的编辑界面中输入</p>
<blockquote><p>*/10 * * * * /home/aaaa/cron.sh</p></blockquote>
<p>再保存就OK了。这样，系统会自动地每10分钟一次将blog的动态主页index.php转成静态的index.html，以后访问主页的时候就会直接访问index.html，从而实现了blog主页面的html静态化。</p>
<p>缺点：COOKIE失效。不过山人自有妙计，<a target="_blank" href="http://www.leexuan.com/2006/05/javascript_cookie.html">使用javascript本地读取COOKIE</a>然后填入表格即可。</p>
<p><strong>效果：明显</strong>。</p>
<h3><font size="3">合并JS和CSS文件</font></h3>
<p>浏览页面的时候，把页面保存下来，便能看到这个页面含有的文件。文件太多，会大大降低浏览速度。而WordPress的插件系统使得JS和CSS文件很多，所以，应当合并一下JS和CSS文件。</p>
<p>手动合并是一个方法，但是容易弄错，而且不太好修改。另一个方法是建立一个新的all.js.php文件，内容是：</p>
<blockquote><p><span style="color: #0000ff">&lt;?</span>php<br />
require_once('目录/wp-blog-header.php' ) ;<br />
<a style="color: #0000ff" href="http://www.php.net/include">include</a> ("<span style="color: #8b0000">/blog/a.js</span>" ) ;<br />
<a style="color: #0000ff" href="http://www.php.net/include">include</a> ("<span style="color: #8b0000">/b.js</span>" ) ;<br />
<span style="color: #0000ff">?&gt;</span></p></blockquote>
<p>就是将header.php里面的那些js文件都include到all.js.php，然后在header里面包含all.js.php文件即可：</p>
<blockquote><p>&lt;script xsrc="<span style="color: #8b0000">all.js.php</span>" type="<span style="color: #8b0000">text/javascript</span>"/&gt;</p></blockquote>
<p>另外还要做的一件事情是需要把原来那些js文件从head里面去掉。通常这些js文件都是通过add_action('wp_head','fun' ) ;这样的钩子添加到head里面的。在fun函数的定义处去掉对应的代码，或者直接把这条语句删除即可。</p>
<p>对CSS文件也可以用同样的处理方式。CSS文件一般都不多，这时候可以直接手动把它们都贴到一起。</p>
<p>另外js文件的载入位置也很重要，放在越后面越好，让浏览器先下载html代码。像Google Analytics的js代码最好放在文件最后。</p>
<p><strong>效果：非常明显</strong>。</p>
<p>另外，太多的图片也会降低载入速度，而我这个模板的图片就比较多，而且我已经把能不用的图片去掉了。想着是不是该换模板了。</p>
<div><h2>相关文章</h2><ul><li><a href="http://zhiqiang.org/blog/it/the-whole-point-of-static-wordpress.html">WordPress全站静态化</a> <small>继上次把主页静态化后，现在本站所有文章都已经是静态的html页面，跟MT系统差不多，当有新文章或者新留言，相关的html文件在后台自动更新。比如这...</small></li><li><a href="http://zhiqiang.org/blog/it/blog-fast-download-speeds-to-be-faster-and-the-speed-of-blog.html">blog下载速度多快才算快和blog速度优化</a> <small>很多人有一个大致的感觉，某blog很慢，或者有点慢，但是似乎还过得去，而没有一个量化的指标。其实对于FireFox浏览器，使fastfox插件，可以在右下方...</small></li><li><a href="http://zhiqiang.org/blog/it/wordpress-21-solution-can-not-remove-the-article-upgrade-to-213.html">WordPress 2.1无法删除文章解决方法 &amp; 升级到2.1.3</a> <small>如果你在升级WordPress到2.1之后遇到以下情况：  无法删除文章(post)在文章列表的"Edit"链接旁边，看不到该有的"Delete"链接。在Edit文章界面，点击"Delete thi...</small></li><li><a href="http://zhiqiang.org/blog/it/how-delete-wordpress-category-base.html">如何去掉category permalink base？</a> <small>一般而言，WordPress的blog的分类category-name地址是http://yoursite/category/category_name，其中/category/称为分类的permalink base，它可以在后台设定为任何字符串。
...</small></li><li><a href="http://zhiqiang.org/blog/it/wordspew-plug-litter-message-solution.html">wordspew插件的垃圾留言的解决办法</a> <small>wordspew插件可以给Blog添加一个实时的ajax聊天窗口，也可以用来当作一个简单留言板，具体效果可见本blog左侧栏的在线聊天模块。本来一直用得挺好的...</small></li><li><a href="http://zhiqiang.org/blog/it/bbpress-installation-problems-and-several-plug-ins.html">bbPress的安装问题和几个插件</a> <small>演示地址：http://zhiqiang.org/bbs/.

bbPress是一个微型论坛程序，官方主页 http://bbpress.org，与WordPress是同一批人开发维护的。主要特点是简洁，且与WordPress...</small></li><li><a href="http://zhiqiang.org/blog/it/wordpress-the-revised-calendar-own-style.html">修改wordpress的自带日历式样</a> <small>wordpress自带了一个日历函数get_calendar()，可以显示每天各发了哪些文章（把鼠标移到日期上即可看到），是个很实用的函数。可是它原来的式样太丑了...</small></li><li><a href="http://zhiqiang.org/blog/it/reading-church-wordpress-plug-in-system-architecture-use.html">阅微堂系统架构 &#038; WordPress插件使用情况</a> <small>本系统使用了以下插件：

	Ajax Comments-Reply: 可以在迴響之後跟隨回覆，使用Ajax無刷新。经过一些修改后，实现本系统的MSN Spaces风格的页面ajax显示和...</small></li><li><a href="http://zhiqiang.org/blog/science/computer-science/move-blogbus-data-to-wordpress.html">BlogBus搬家文件转WordPress导入文件</a> <small>  最近给某blog做了一次搬家，从Sina转到WordPress独立博客，网上已经有很多工具和方法，但可用而且耗用的不多，总是有一些乱七八糟的问题。这里说一...</small></li><li><a href="http://zhiqiang.org/blog/it/wordpress-create-the-most-efficient-of-all-stations-browsing.html">打造最快捷的wordpress的全站浏览方式</a> <small>我们有很多种方式浏览全站文章，主页面往前翻页，通过察看分类和按日期存档察看，或者通过搜索查找自己敢兴趣的东西。这些方法的缺陷就是太慢...</small></li></ul></div>    <p></p>
    <hr noshade style="margin:0;height:1px" />
    <p>&copy; zhiqiang for <a href="http://zhiqiang.org/blog">阅微堂</a>, 2006. | <a href="http://zhiqiang.org/blog/it/wordpress-accelerate-the-pace-of-pages-printed-in-the-generation-and.html">&#38142;&#25509;</a> | <a href="http://zhiqiang.org/blog/it/wordpress-accelerate-the-pace-of-pages-printed-in-the-generation-and.html#comments">49 &#26465;&#35780;&#35770;</a></p>]]></content:encoded>
			<wfw:commentRss>http://zhiqiang.org/blog/it/wordpress-accelerate-the-pace-of-pages-printed-in-the-generation-and.html/feed</wfw:commentRss>
		<slash:comments>49</slash:comments>
		</item>
	</channel>
</rss>
