<?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; WordPress优化</title> <atom:link href="http://zou.lu/tags/wordpress%e4%bc%98%e5%8c%96/feed/" rel="self" type="application/rss+xml" /><link>http://zou.lu</link> <description>走点路，走自己牛逼的路，让那些个傻逼去说吧！</description> <lastBuildDate>Sun, 25 Jul 2010 19:09:27 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <item><title>更换空间 + 再次提速之 Gravatar 头像缓存</title><link>http://zou.lu/change-hosting-and-cache-gravatar/</link> <comments>http://zou.lu/change-hosting-and-cache-gravatar/#comments</comments> <pubDate>Wed, 02 Sep 2009 04:01:34 +0000</pubDate> <dc:creator>Showfom</dc:creator> <category><![CDATA[WordPress]]></category> <category><![CDATA[日志便笺]]></category> <category><![CDATA[Gravatar]]></category> <category><![CDATA[WordPress优化]]></category> <category><![CDATA[缓存]]></category><guid isPermaLink="false">http://zou.lu/change-hosting-and-cache-gravatar/</guid> <description><![CDATA[博客得追求速度，速度得靠空间和优化，最近网通有点抽风，为了心爱的博客，不得不再次提速。 这次搬家到易联了，Tension 开办的公司，暑假我去过他们公司蹭饭，见到可爱的秋爱大叔（听说他回老家了），顺便蹭饭蹭网哈哈。 小T长得一表人才的说，是个技术狂，哦不，是设计狂，做的几款主题都很精致，那天还吹牛说他直接写的主题能“完美兼容所有的浏览器”哈哈。 暑假去了趟北京，上回 WordCamp 又去了趟北京，真的和北京很有缘分。 以前用的酋长的空间挺不错的，但是最近网络抽风厉害，网通和电信的线路就这样了，易联的速度还过得去，当然我用电信的时候，Wopus 的速度和易联的速度还是差不多的，也就不多做评论了。 现在我博客的速度如何，至少我这里网通还是很快，上传速度是慢了点，不过没那么多东西要传，还是能忍受哈。 易联总共有三个套餐：http://www.elinkhost.com/ 我买的是第二个： 顺便帮小T童鞋推广一下，购买付款之前，有个优惠码的选项，填写 Showfom.Com （注意大小写），即可获得85折的优惠，要是你博客流量不大，可以选择入门型的，一年就255块，很划算。 一起用易联的博友们有：异次元软件世界、Sivan、 帕兰、 Sofish 等朋友，基本上都是认识的几个家伙，人品过得去，不会乱来的哈哈，所以可以放心使用啦。 空间问题算是解决了，接下来就要再次加快速度，继以前几篇优化的文章之后，这次教大家如何优化 Gravatar 头像本地缓存。 ========= 上个月海底光缆断了，结果网通访问 Gravatar 超慢，博客留言里的头像基本都显示不了，假如能把头像直接缓存到本地，那速度绝对大大加快，那么能否实现这种功能呢？答案是肯定的。 首先，看一下默认 Gravatar 头像的地址，比如我的： http://www.gravatar.com/avatar/8406d089bc81b664a2610b8d214c1428 可以看到，后面一串数字和字母的组合，就是 Email 的 md5 值，那么，只要用服务器下载来头像，然后直接用这种形式展现出头像，修改模板的 comments.php 文件，理论上很简单，实际上呢？也很简单…… 说一下方法吧： 1、下载一个 GRAVATAR CACHE 的程序，注意，不是 WordPress 插件，只是一个缓存头像的程序。 下载地址：http://scott.yang.id.au/code/gravatar-cache/#toc-download 最新版本是 0.2 ，07年发布的，原理简单嘛，照样可以用。 2、下载以后解压，打开 index.php ，根据你的需要修改如下代码： $config = array( 'gravatar' [...]]]></description> <content:encoded><![CDATA[<p>博客得追求速度，速度得靠空间和优化，最近网通有点抽风，为了心爱的博客，不得不再次提速。</p><p><span id="more-98"></span></p><p>这次搬家到<a href="http://www.elinkhost.com/" target="_blank">易联</a>了，<a href="http://tension.name/" target="_blank">Tension</a> 开办的公司，暑假我去过他们公司<a href="http://zou.lu/back-home-2009/" target="_blank">蹭饭</a>，见到可爱的<a href="http://qiuai.name/" target="_blank">秋爱</a>大叔（听说他回老家了），顺便蹭饭蹭网哈哈。</p><p>小T长得一表人才的说，是个技术狂，哦不，是设计狂，做的几款主题都很精致，那天还吹牛说他直接写的主题能“完美兼容所有的浏览器”哈哈。</p><p>暑假去了趟北京，上回 <a href="http://zou.lu/wordcamp-2009-ends/" target="_blank">WordCamp</a> 又去了趟北京，真的和北京很有缘分。</p><p>以前用的酋长的空间挺不错的，但是最近网络抽风厉害，网通和电信的线路就这样了，易联的速度还过得去，当然我用电信的时候，<a href="http://wopus.org/" target="_blank">Wopus</a> 的速度和易联的速度还是差不多的，也就不多做评论了。</p><p>现在我博客的速度如何，至少我这里网通还是很快，上传速度是慢了点，不过没那么多东西要传，还是能忍受哈。</p><p>易联总共有三个套餐：<a href="http://www.elinkhost.com/" target="_blank">http://www.elinkhost.com/</a></p><p>我买的是第二个：</p><p><a href="//showfom.imgbed.com/Gravatar_A90C/image.png" class="highslide-image" onclick="return hs.expand(this);"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="易联" src="//showfom.imgbed.com/Gravatar_A90C/image_thumb.png" border="0" alt="易联" width="186" height="244" /></a></p><p>顺便帮小T童鞋推广一下，购买付款之前，有个优惠码的选项，填写<span style="font-size: medium;"> <strong><span style="color: #ff0000;">Showfom.Com</span></strong></span> （注意大小写），即可获得85折的优惠，要是你博客流量不大，可以选择入门型的，一年就255块，很划算。</p><p>一起用易联的博友们有：<a href="http://www.iplaysoft.com/" target="_blank">异次元软件世界</a>、<a href="http://sivan.in/blog/" target="_blank">Sivan</a>、 <a href="http://paranimage.com/" target="_blank">帕兰</a>、 <a href="http://www.happinesz.cn/" target="_blank">Sofish</a> 等朋友，基本上都是认识的几个家伙，人品过得去，不会乱来的哈哈，所以可以放心使用啦。</p><p>空间问题算是解决了，接下来就要再次加快速度，继以前几篇优化的文章之后，这次教大家如何优化 <a href="http://www.gravatar.com/" target="_blank">Gravatar</a> 头像本地缓存。</p><p>=========</p><p>上个月海底光缆断了，结果网通访问 Gravatar 超慢，博客留言里的头像基本都显示不了，假如能把头像直接缓存到本地，那速度绝对大大加快，那么能否实现这种功能呢？答案是肯定的。</p><p>首先，看一下默认<strong> Gravatar</strong> 头像的地址，比如我的：</p><p><a title="http://www.gravatar.com/avatar/8406d089bc81b664a2610b8d214c1428" href="http://www.gravatar.com/avatar/8406d089bc81b664a2610b8d214c1428">http://www.gravatar.com/avatar/8406d089bc81b664a2610b8d214c1428</a></p><p>可以看到，后面一串数字和字母的组合，就是 Email 的 md5 值，那么，只要用服务器下载来头像，然后直接用这种形式展现出头像，修改模板的 comments.php 文件，理论上很简单，实际上呢？也很简单……</p><p>说一下方法吧：</p><p>1、下载一个 <strong>GRAVATAR CACHE</strong> 的程序，注意，不是<strong> WordPress</strong> 插件，只是一个缓存头像的程序。</p><p>下载地址：<a title="http://scott.yang.id.au/code/gravatar-cache/#toc-download" href="http://scott.yang.id.au/code/gravatar-cache/#toc-download">http://scott.yang.id.au/code/gravatar-cache/#toc-download</a></p><p>最新版本是 0.2 ，07年发布的，原理简单嘛，照样可以用。</p><p>2、下载以后解压，打开 <em><strong>index.php</strong> </em>，根据你的需要修改如下代码：</p><div class="source" style="background-color: #1e1e27; font-family: &quot;None&quot;,&quot;Consolas&quot;,&quot;Lucida Console&quot;,&quot;Courier New&quot;; color: #ffffff"><span style="color: #fb660a">$config</span> <span style="color: #ffffff">=</span> <span style="color: #fb660a; font-weight: bold">array</span>(<br /> <span style="color: #0086d2">'gravatar'</span> <span style="color: #ffffff">=&gt;</span> <span style="color: #0086d2">'http://www.gravatar.com/avatar.php'</span><span style="color: #ffffff">,</span><br /> <span style="color: #0086d2">'rating'</span> <span style="color: #ffffff">=&gt;</span> <span style="color: #0086d2">'PG'</span><span style="color: #ffffff">,</span> <span style="background-color: #0f140f; font-style: italic; color: #008800">//默认头像等级</span><br /> <span style="color: #0086d2">'size'</span> <span style="color: #ffffff">=&gt;</span> <span style="color: #0086f7; font-weight: bold">64</span><span style="color: #ffffff">,</span> <span style="background-color: #0f140f; font-style: italic; color: #008800">//默认头像宽度高度</span><br /> <span style="color: #0086d2">'default'</span> <span style="color: #ffffff">=&gt;</span> <span style="color: #0086d2">''</span><span style="color: #ffffff">,</span><br /> <span style="color: #0086d2">'border'</span> <span style="color: #ffffff">=&gt;</span> <span style="color: #0086d2">''</span><span style="color: #ffffff">,</span><br /> <span style="color: #0086d2">'referrer'</span> <span style="color: #ffffff">=&gt;</span> <span style="color: #0086d2">''</span><span style="color: #ffffff">,</span><br /> <span style="color: #0086d2">'pos_expiry'</span> <span style="color: #ffffff">=&gt;</span> <span style="color: #0086f7; font-weight: bold">604800</span><span style="color: #ffffff">,</span><br /> <span style="color: #0086d2">'neg_expiry'</span> <span style="color: #ffffff">=&gt;</span> <span style="color: #0086f7; font-weight: bold">43200</span><span style="color: #ffffff">,</span><br /> <span style="color: #0086d2">'neg_handler'</span> <span style="color: #ffffff">=&gt;</span> <span style="color: #0086d2">'file'</span><span style="color: #ffffff">,</span><br /> <span style="color: #0086d2">'proxy'</span> <span style="color: #ffffff">=&gt;</span> <span style="color: #0086d2">''</span><span style="color: #ffffff">,</span><br /> <span style="color: #0086d2">'basedir'</span> <span style="color: #ffffff">=&gt;</span> <span style="color: #ffffff">dirname</span>(<span style="color: #fb660a; font-weight: bold">__FILE__</span><span style="color: #ffffff">),</span><br /> <span style="color: #0086d2">'x-sendfile'</span> <span style="color: #ffffff">=&gt;</span> <span style="color: #fb660a; font-weight: bold">false</span><span style="color: #ffffff">,</span><br /> <span style="color: #0086d2">'debug'</span> <span style="color: #ffffff">=&gt;</span> <span style="color: #fb660a; font-weight: bold">false</span><br /> );</div><p>接着，在<strong> profile</strong> 目录，创建一个名为 <strong>avatar.php</strong> 的文件，用非记事本输入以下字符：</p><div class="source" style="background-color: #1e1e27; font-family: &quot;None&quot;,&quot;Consolas&quot;,&quot;Lucida Console&quot;,&quot;Courier New&quot;; color: #ffffff"><span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">&lt;?php</span><br /> <span style="color: #fb660a">$config</span><span style="color: #ffffff">[</span><span style="color: #0086d2">'default'</span><span style="color: #ffffff">]</span> <span style="color: #ffffff">=</span> <span style="color: #0086d2">'http://默认头像URL/'</span>; <span style="background-color: #0f140f; font-style: italic; color: #008800">//无头像时返回的默认头像路径</span><br /> <span style="color: #fb660a">$config</span><span style="color: #ffffff">[</span><span style="color: #0086d2">'rating'</span><span style="color: #ffffff">]</span> <span style="color: #ffffff">=</span> <span style="color: #0086d2">'X'</span>;<span style="background-color: #0f140f; font-style: italic; color: #008800">//gravatar的内容级别</span><br /> <span style="color: #fb660a">$config</span><span style="color: #ffffff">[</span><span style="color: #0086d2">'size'</span><span style="color: #ffffff">]</span> <span style="color: #ffffff">=</span> <span style="color: #0086f7; font-weight: bold">50</span>;<span style="background-color: #0f140f; font-style: italic; color: #008800">//头像尺寸</span><br /> <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">?&gt;</span></div><p>保存为 <strong>UTF-8</strong> 编码哦</p><p>接着，打开<strong> .htaccess</strong> 文件：</p><div class="source" style="background-color: #1e1e27; font-family: &quot;None&quot;,&quot;Consolas&quot;,&quot;Lucida Console&quot;,&quot;Courier New&quot;; color: #ffffff"><span style="color: #ffffff">&lt;IfModule mod_rewrite.c&gt;</span><br /> <span style="color: #ffffff">RewriteEngine On</span><br /> <span style="color: #ffffff">RewriteCond %{REQUEST_FILENAME} !-f</span><br /> <span style="color: #ffffff">RewriteCond %{REQUEST_FILENAME} !-d</span><br /> <span style="color: #ffffff">RewriteRule . /index.php [L]</span><br /> <span style="color: #ffffff">&lt;/IfModule&gt;</span></div><p>假如你存放的目录为 <strong>gravatar</strong> 则倒数第二行要修改为<strong> RewriteRule . /gravatar/index.php [L]</strong></p><p>然后上传 即可</p><p><strong>Nginx</strong> 下的规则是：</p><div class="source" style="background-color: #1e1e27; font-family: &quot;None&quot;,&quot;Consolas&quot;,&quot;Lucida Console&quot;,&quot;Courier New&quot;; color: #ffffff"><span style="color: #ffffff">if (!-f $request_filename){</span><br /> <span style="color: #ffffff"> set $rule_0 1$rule_0;</span><br /> <span style="color: #ffffff">}</span><br /> <span style="color: #ffffff">if (!-d $request_filename){</span><br /> <span style="color: #ffffff"> set $rule_0 2$rule_0;</span><br /> <span style="color: #ffffff">}</span><br /> <span style="color: #ffffff">if ($rule_0 = "21"){</span><br /> <span style="color: #ffffff"> rewrite /. /index.php last;</span><br /> <span style="color: #ffffff">}</span></div><p>接着后台修改主题文件的 <strong>comments.php</strong>， 找到类似以下代码：</p><div class="source" style="background-color: #1e1e27; font-family: &quot;None&quot;,&quot;Consolas&quot;,&quot;Lucida Console&quot;,&quot;Courier New&quot;; color: #ffffff"><span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">&lt;?php</span> <span style="color: #fb660a; font-weight: bold">echo</span> <span style="color: #ffffff">get_avatar</span>( <span style="color: #fb660a">$comment</span><span style="color: #ffffff">,</span> <span style="color: #0086f7; font-weight: bold">50</span> ); <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">?&gt;</span></div><p>替换成：</p><div class="source" style="background-color: #1e1e27; font-family: &quot;None&quot;,&quot;Consolas&quot;,&quot;Lucida Console&quot;,&quot;Courier New&quot;; color: #ffffff"><span style="color: #ffffff">&lt;img src="http://你的缓存地址/cache/avatar/</span><span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">&lt;?php</span> <span style="color: #fb660a; font-weight: bold">echo</span> <span style="color: #ffffff">md5</span>(<span style="color: #ffffff">strtolower</span>(<span style="color: #fb660a">$comment</span><span style="color: #ffffff">-&gt;</span><span style="color: #ff0086; font-weight: bold">comment_author_email</span>)); <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">?&gt;</span><span style="color: #ffffff">" alt="" /&gt;</span></div><p>即可。</p><p>假如你的主题符合 <strong>WordPress 2.7+ </strong>标准，没有此代码，只有一行这样的代码：</p><div class="source" style="background-color: #1e1e27; font-family: &quot;None&quot;,&quot;Consolas&quot;,&quot;Lucida Console&quot;,&quot;Courier New&quot;; color: #ffffff"><span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">&lt;?php</span> <span style="color: #ffffff">wp_list_comments</span>(); <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">?&gt;</span></div><p>那么就得修改 <strong>comments.php</strong> 和 <strong>functions.php</strong> 了， 甚至，可以参考一些<strong> WordPress 2.7+</strong> 的皮肤，留言样式是自定义的，比如 <a href="http://www.neoease.com/" target="_blank">mg12</a> 制作的 iNove 主题（他的留言样式都是自定义的，参考<strong> comments.php</strong> 和 <strong>functions.php</strong>）</p><p>举个简单的例子：</p><p><strong>comments.php</strong> 里自定义 <strong>wp_list_comments();</strong></p><div class="source" style="background-color: #1e1e27; font-family: &quot;None&quot;,&quot;Consolas&quot;,&quot;Lucida Console&quot;,&quot;Courier New&quot;; color: #ffffff"><span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">&lt;?php</span> <span style="color: #ffffff">wp_list_comments</span>(<span style="color: #fb660a; font-weight: bold">array</span> (<span style="color: #0086d2">'type'</span> <span style="color: #ffffff">=&gt;</span> <span style="color: #0086d2">'comment'</span><span style="color: #ffffff">,</span><span style="color: #0086d2">'callback'</span> <span style="color: #ffffff">=&gt;</span> <span style="color: #0086d2">'custom_comments'</span>)); <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">?&gt;</span></div><p><strong>functions.php</strong> 里再自定义评论样式</p><div class="source" style="background-color: #1e1e27; font-family: &quot;None&quot;,&quot;Consolas&quot;,&quot;Lucida Console&quot;,&quot;Courier New&quot;; color: #ffffff"><span style="color: #ffffff">// custom comments</span><br /> <span style="color: #ffffff">function custom_comments($comment, $args, $depth) {</span><br /> <span style="color: #ffffff"> $GLOBALS['comment'] = $comment;</span><br /> <span style="color: #ffffff"> global $commentcount;</span><br /> <span style="color: #ffffff"> if(!$commentcount) {</span><br /> <span style="color: #ffffff"> $commentcount = 0;</span><br /> <span style="color: #ffffff"> }</span><br /> <span style="color: #ffffff">?&gt;</span><br /> <span style="color: #ffffff"> &lt;li class="comment </span><span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">&lt;?php</span> <span style="color: #fb660a; font-weight: bold">if</span>(<span style="color: #fb660a">$comment</span><span style="color: #ffffff">-&gt;</span><span style="color: #ff0086; font-weight: bold">comment_author_email</span> <span style="color: #ffffff">==</span> <span style="color: #ffffff">get_the_author_email</span>()) <span style="color: #ffffff">{</span><span style="color: #fb660a; font-weight: bold">echo</span> <span style="color: #0086d2">'admincomment'</span><span style="color: #ffffff">;}</span> <span style="color: #fb660a; font-weight: bold">else</span> <span style="color: #ffffff">{</span><span style="color: #fb660a; font-weight: bold">echo</span> <span style="color: #0086d2">'regularcomment'</span><span style="color: #ffffff">;}</span> <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">?&gt;</span><span style="color: #ffffff">" id="comment-</span><span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">&lt;?php</span> <span style="color: #ffffff">comment_ID</span>() <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">?&gt;</span><span style="color: #ffffff">"&gt;</span><br /> <span style="color: #ffffff"> &lt;div class="author"&gt;</span><br /> <span style="color: #ffffff"> &lt;div class="pic"&gt;</span><br /> <span style="color: #ffffff"> &lt;img src="http://你的缓存地址/cache/avatar/</span><span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">&lt;?php</span> <span style="color: #fb660a; font-weight: bold">echo</span> <span style="color: #ffffff">md5</span>(<span style="color: #ffffff">strtolower</span>(<span style="color: #fb660a">$comment</span><span style="color: #ffffff">-&gt;</span><span style="color: #ff0086; font-weight: bold">comment_author_email</span>)); <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">?&gt;</span><span style="color: #ffffff">" alt="" /&gt; </span><br /> <span style="color: #ffffff"> &lt;/div&gt;</span><br /> <span style="color: #ffffff"> &lt;div class="name"&gt;</span><br /> <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">&lt;?php</span> <span style="color: #fb660a; font-weight: bold">if</span> (<span style="color: #ffffff">get_comment_author_url</span>()) <span style="color: #ffffff">:</span> <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">?&gt;</span><br /> <span style="color: #ffffff"> &lt;a id="commentauthor-</span><span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">&lt;?php</span> <span style="color: #ffffff">comment_ID</span>() <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">?&gt;</span><span style="color: #ffffff">" class="url" href="</span><span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">&lt;?php</span> <span style="color: #ffffff">comment_author_url</span>() <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">?&gt;</span><span style="color: #ffffff">" rel="external nofollow"&gt;</span><br /> <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">&lt;?php</span> <span style="color: #fb660a; font-weight: bold">else</span> <span style="color: #ffffff">:</span> <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">?&gt;</span><br /> <span style="color: #ffffff"> &lt;span id="commentauthor-</span><span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">&lt;?php</span> <span style="color: #ffffff">comment_ID</span>() <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">?&gt;</span><span style="color: #ffffff">"&gt;</span><br /> <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">&lt;?php</span> <span style="color: #fb660a; font-weight: bold">endif</span>; <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">?&gt;</span></p><p><span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">&lt;?php</span> <span style="color: #ffffff">comment_author</span>(); <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">?&gt;</span></p><p><span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">&lt;?php</span> <span style="color: #fb660a; font-weight: bold">if</span>(<span style="color: #ffffff">get_comment_author_url</span>()) <span style="color: #ffffff">:</span> <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">?&gt;</span><br /> <span style="color: #ffffff"> &lt;/a&gt;</span><br /> <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">&lt;?php</span> <span style="color: #fb660a; font-weight: bold">else</span> <span style="color: #ffffff">:</span> <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">?&gt;</span><br /> <span style="color: #ffffff"> &lt;/span&gt;</span><br /> <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">&lt;?php</span> <span style="color: #fb660a; font-weight: bold">endif</span>; <span style="background-color: #0f140f; font-style: italic; color: #ff0007; font-weight: bold">?&gt;</span><br /> <span style="color: #ffffff"> &lt;/div&gt;</span><br /> <span style="color: #ffffff"> &lt;/div&gt;</span></div><p>具体的样式，即 <strong>functions.php</strong> 里的代码得参考你自己的评论样式，不再详细叙述，总之就是找到原来放置头像的地方，修改成：</p><blockquote><p>&lt;img src="http://你的缓存地址/cache/avatar/&lt;?php echo md5(strtolower($comment-&gt;comment_author_email)); ?&gt;" alt="" /&gt;</p></blockquote><p>即可</p><p>再不懂的，我也无能为力了，囧……<strong>WordPress 2.7+</strong> 以后的 <strong>comments.php</strong> 就是麻烦……</p><p>（方法来自 <a href="http://ishawn.net/">iShawn</a> 的博客 ： <a href="http://ishawn.net/my-blog-related/cache-gravatar-into-local-server.html">如何缓存 Gravatar 至本地服务器</a>）</p><h2  class="related_post_title">相关文章</h2><ul class="related_post"><li><a href="http://zou.lu/optimize-wordpress-themes-html-codes/" title="优化你的 WordPress 之精简全站 HTML 代码（终极篇）">优化你的 WordPress 之精简全站 HTML 代码（终极篇）</a> (90)</li><li><a href="http://zou.lu/optimize-wordpress-themes-css-and-js-codes/" title="优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）">优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）</a> (79)</li><li><a href="http://zou.lu/optimize-wordpress-database-query-middle-object-cache/" title="优化你的 WordPress 之减少数据库查询次数（中级篇补充之 Object Cache）">优化你的 WordPress 之减少数据库查询次数（中级篇补充之 Object Cache）</a> (43)</li><li><a href="http://zou.lu/optimize-wordpress-database-query-middle/" title="优化你的 WordPress 之减少数据库查询次数（中级篇）">优化你的 WordPress 之减少数据库查询次数（中级篇）</a> (30)</li><li><a href="http://zou.lu/optimize-wordpress-themes-codes-normal/" title="优化你的 WordPress 之精简 HTML 代码（进阶篇）">优化你的 WordPress 之精简 HTML 代码（进阶篇）</a> (32)</li><li><a href="http://zou.lu/optimize-wordpress-database-query-rookie/" title="优化你的 WordPress 之减少数据库查询次数（初级篇）">优化你的 WordPress 之减少数据库查询次数（初级篇）</a> (28)</li></ul><hr /><div style="padding: 5px 10px; background: rgb(243, 245, 252) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"><p>© from <a href="//zou.lu/?from=feed">走点路博客</a>, 2009/09/02. | <a href="http://zou.lu/change-hosting-and-cache-gravatar/">更换空间 + 再次提速之 Gravatar 头像缓存</a> | <a href="http://zou.lu/change-hosting-and-cache-gravatar/#comments">135 只留言鸟</a> <br /> Tags： <a href="http://zou.lu/tags/gravatar/" rel="tag">Gravatar</a>, <a href="http://zou.lu/tags/wordpress%e4%bc%98%e5%8c%96/" rel="tag">WordPress优化</a>, <a href="http://zou.lu/tags/%e7%bc%93%e5%ad%98/" rel="tag">缓存</a> | <a href="//zou.lu/?p=98">Link</a> | <a href="http://zi.mu/domain"><font color="red">.me 域名全国最低价，首年仅需40元，续费130元促销中！</font></a></p></div>]]></content:encoded> <wfw:commentRss>http://zou.lu/change-hosting-and-cache-gravatar/feed/</wfw:commentRss> <slash:comments>135</slash:comments> </item> <item><title>优化你的 WordPress 之精简全站 HTML 代码（终极篇）</title><link>http://zou.lu/optimize-wordpress-themes-html-codes/</link> <comments>http://zou.lu/optimize-wordpress-themes-html-codes/#comments</comments> <pubDate>Tue, 28 Jul 2009 12:01:14 +0000</pubDate> <dc:creator>Showfom</dc:creator> <category><![CDATA[WordPress]]></category> <category><![CDATA[Autoptimize]]></category> <category><![CDATA[WordPress优化]]></category><guid isPermaLink="false">http://zou.lu/optimize-wordpress-themes-html-codes/</guid> <description><![CDATA[WordPress 优化，优化主题的代码是关键一步，但是，假如按照我们设想的，完全把 HTML代码 进行优化，可读性一定很差，不利于二次修改，所以，本次推出终极优化 HTML 代码之优化小王子 —— Autoptimize。 至于最终的效果，大家可以看我的博客源代码，首页的，页面的，文章的，是不是感觉很杂乱，但是显示出来的效果并没有任何差异，在这个节省流量的年代，哪怕是一个字节都会影响到整个网络（Google 语），仔细观察 Google、百度 这些超大流量的网站，他们的源代码无一不是和我现在博客的源代码类似。 那么，怎么做到呢？总不至于人工去合成吧（废话，那得花多少时间呀！），这时候，我们的优化小王子 —— Autoptimize 插件登场，蹬蹬蹬蹬！ ====== Autoptimize 的工作原理 通过优化HTML代码（去除不必要的空格、换行、注释）、CSS代码、JS代码，缓存起来，然后访问的时候输出，访客访问到的是经过优化后的代码，很大程度上节省了流量，同时作者推荐和 WP Super Cache 插件一起使用。Showfom 小帅锅的建议是，流量不足3000IP之前不用考虑 WP Super Cache，使用 Autoptimize 进行代码优化以后然后gzip输出之，就很完美了。 &#160; Autoptimize 安装使用方法 下载，上传，激活，后台设置，WordPress 的插件就是如此简单。 下载地址：http://wordpress.org/extend/plugins/autoptimize/&#160; （或者通过后台搜索 Autoptimize 在线安装，中文版由 Donald 翻译，下载在此：http://zuoshen.com/2009/07/20/642/） 设置讲解图： &#160; Autoptimize 忌讳几则 1、假如样式出错，就不要选择优化 CSS 代码，自己优化是个好方法；同样，假如功能出错，请不要优化 JS 代码，自己优化是个好方法，至于自行优化 CSS 和 JS 代码，参考前文：《优化你的 WordPress [...]]]></description> <content:encoded><![CDATA[<p><strong>WordPress 优化</strong>，优化主题的代码是关键一步，但是，假如按照我们设想的，完全把 <strong>HTML代码</strong> 进行优化，可读性一定很差，不利于二次修改，所以，本次推出终极优化<strong> HTML 代码</strong>之优化小王子 ——<strong> </strong><a title="Autoptimize" href="http://www.turleando.com.ar/autoptimize/" target="_blank"><strong>Autoptimize</strong></a>。</p><p> <span id="more-84"></span><p>至于最终的效果，大家可以看我的博客源代码，首页的，页面的，文章的，是不是感觉很杂乱，但是显示出来的效果并没有任何差异，在这个节省流量的年代，哪怕是一个字节都会影响到整个网络（<strong>Google 语</strong>），仔细观察 <strong>Google</strong>、<strong>百度</strong> 这些超大流量的网站，他们的源代码无一不是和我现在博客的源代码类似。</p><p>那么，怎么做到呢？总不至于人工去合成吧（废话，那得花多少时间呀！），这时候，我们的优化小王子 —— Autoptimize 插件登场，蹬蹬蹬蹬！</p><p>======</p><h2>Autoptimize 的工作原理</h2><p>通过优化<strong>HTML代码</strong>（去除不必要的空格、换行、注释）、<strong>CSS代码</strong>、<strong>JS代码</strong>，缓存起来，然后访问的时候输出，访客访问到的是经过优化后的代码，很大程度上节省了流量，同时作者推荐和 <a title="WP Super Cache" href="http://wordpress.org/extend/plugins/wp-super-cache/" target="_blank"><strong>WP Super Cache</strong></a> 插件一起使用。<strong>Showfom 小帅锅</strong>的建议是，流量不足3000IP之前不用考虑 WP Super Cache，使用 <strong>Autoptimize</strong> 进行代码优化以后然后<strong>gzip</strong>输出之，就很完美了。</p><p>&#160;</p><h2>Autoptimize 安装使用方法</h2><p>下载，上传，激活，后台设置，<strong>WordPress </strong>的插件就是如此简单。</p><p>下载地址：<a title="http://wordpress.org/extend/plugins/autoptimize/" href="http://wordpress.org/extend/plugins/autoptimize/">http://wordpress.org/extend/plugins/autoptimize/</a>&#160; （或者通过后台搜索 <strong>Autoptimize</strong> 在线安装，中文版由 <a title="Donald" href="http://zuoshen.com/" target="_blank"><strong>Donald</strong></a> 翻译，下载在此：<a title="用Autoptimize给你的WordPress再提点速，中文语言文件已添加！" href="http://zuoshen.com/2009/07/20/642/" target="_blank">http://zuoshen.com/2009/07/20/642/</a>）</p><p>设置讲解图：</p><p><a href="//showfom.imgbed.com/WordPressHTML_11959/image.png" class="highslide-image" onclick="return hs.expand(this);"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Autoptimize" border="0" alt="Autoptimize" src="//showfom.imgbed.com/WordPressHTML_11959/image_thumb.png" width="638" height="484" /></a></p><p>&#160;</p><h2>Autoptimize 忌讳几则</h2><p>1、假如样式出错，就不要选择优化<strong> CSS</strong> 代码，自己优化是个好方法；同样，假如功能出错，请不要优化<strong> JS</strong> 代码，自己优化是个好方法，至于自行优化 <strong>CSS </strong>和<strong> JS</strong> 代码，参考前文：<strong>《</strong><a title="优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）" href="http://zou.lu/optimize-wordpress-themes-css-and-js-codes/" target="_blank"><strong>优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）</strong></a><strong>》。</strong></p><p>2、一般情况下，优化<strong> HTML 代码</strong>是不会出错的，原理只是删除了多余的空格、空行和注释而已，假如出错，请自行检查不该优化的代码并且写入 <strong>JS</strong>。</p><p>3、<strong>Autoptimize </strong>的原理只是前台进行优化，后台编辑主题里的代码不用修改，所以对于网页设计师来说，为了防止别人抄袭代码也好，为了节省流量提高速度也好，这款插件实在是必不可少。</p><p>========</p><p><strong>PS：</strong>有个<strong>PLMM</strong>问偶，<strong>Showfom 小帅锅</strong>，你的做法是什么？</p><p>答：我的做法和我给出的图解一样，只是优化了<strong> HTML代码</strong> 而已，因为不太会出错，<strong>CSS</strong> 和<strong> JS</strong> 都是我自行<a title="优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）" href="http://zou.lu/optimize-wordpress-themes-css-and-js-codes/" target="_blank">优化</a>的，谢谢你的崇拜。</p><p><strong>再次PS：</strong>请确定主题确定功能以后再进行 <strong>WordPress </strong>的代码优化工作，优化切记备份，优化后，前台直接看源代码可读性不是一般的差，所以，谨慎优化。至于什么 <strong>Yslow </strong>这些可有可无的测试得分之类的，见他妈的鬼去吧，我才不会吃的空把所有图片都合并成一张，要 <strong>CSS </strong>里只输出一张图片是个很费精力的活，雅虎那个东西，自己的首页的代码都那么乱七八糟，我就不评价了，一般75分以上就没问题了，放国内的空间速度都刷刷的……</p><p><strong>再再次PS：</strong>优化 <strong>WordPress </strong>主题的代码系列文章到此结束，接下来我也要学学缓存插件之类的优化，不过貌似人气没那么高以前，我也是懒得用缓存插件的人，所以，下一篇系列文章就要在以后和大家见面了，嘎嘎~</p><h2  class="related_post_title">相关文章</h2><ul class="related_post"><li><a href="http://zou.lu/optimize-wordpress-themes-css-and-js-codes/" title="优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）">优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）</a> (79)</li><li><a href="http://zou.lu/optimize-wordpress-database-query-middle-object-cache/" title="优化你的 WordPress 之减少数据库查询次数（中级篇补充之 Object Cache）">优化你的 WordPress 之减少数据库查询次数（中级篇补充之 Object Cache）</a> (43)</li><li><a href="http://zou.lu/optimize-wordpress-database-query-middle/" title="优化你的 WordPress 之减少数据库查询次数（中级篇）">优化你的 WordPress 之减少数据库查询次数（中级篇）</a> (30)</li><li><a href="http://zou.lu/optimize-wordpress-themes-codes-normal/" title="优化你的 WordPress 之精简 HTML 代码（进阶篇）">优化你的 WordPress 之精简 HTML 代码（进阶篇）</a> (32)</li><li><a href="http://zou.lu/optimize-wordpress-database-query-rookie/" title="优化你的 WordPress 之减少数据库查询次数（初级篇）">优化你的 WordPress 之减少数据库查询次数（初级篇）</a> (28)</li><li><a href="http://zou.lu/use-cook-free-domain-for-your-wordpress/" title="提高 WordPress 速度之独立域名图床">提高 WordPress 速度之独立域名图床</a> (160)</li><li><a href="http://zou.lu/wpjam/" title="WordPress Jam &#8211; WP 建站服务一条龙">WordPress Jam &#8211; WP 建站服务一条龙</a> (63)</li><li><a href="http://zou.lu/mobilepress-themes-fixed/" title="MobilePress 主题汉化并修改">MobilePress 主题汉化并修改</a> (73)</li><li><a href="http://zou.lu/private-themes/" title="换上私人主题 + 清理友链">换上私人主题 + 清理友链</a> (187)</li><li><a href="http://zou.lu/chinese-beauties-in-wordpress-ii/" title="WordPress 中文界的美女们（第二期，有照片）">WordPress 中文界的美女们（第二期，有照片）</a> (309)</li></ul><hr /><div style="padding: 5px 10px; background: rgb(243, 245, 252) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"><p>© from <a href="//zou.lu/?from=feed">走点路博客</a>, 2009/07/28. | <a href="http://zou.lu/optimize-wordpress-themes-html-codes/">优化你的 WordPress 之精简全站 HTML 代码（终极篇）</a> | <a href="http://zou.lu/optimize-wordpress-themes-html-codes/#comments">90 只留言鸟</a> <br /> Tags： <a href="http://zou.lu/tags/autoptimize/" rel="tag">Autoptimize</a>, <a href="http://zou.lu/tags/wordpress/" rel="tag">WordPress</a>, <a href="http://zou.lu/tags/wordpress%e4%bc%98%e5%8c%96/" rel="tag">WordPress优化</a> | <a href="//zou.lu/?p=84">Link</a> | <a href="http://zi.mu/domain"><font color="red">.me 域名全国最低价，首年仅需40元，续费130元促销中！</font></a></p></div>]]></content:encoded> <wfw:commentRss>http://zou.lu/optimize-wordpress-themes-html-codes/feed/</wfw:commentRss> <slash:comments>90</slash:comments> </item> <item><title>优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）</title><link>http://zou.lu/optimize-wordpress-themes-css-and-js-codes/</link> <comments>http://zou.lu/optimize-wordpress-themes-css-and-js-codes/#comments</comments> <pubDate>Mon, 27 Jul 2009 16:33:05 +0000</pubDate> <dc:creator>Showfom</dc:creator> <category><![CDATA[WordPress]]></category> <category><![CDATA[WordPress优化]]></category><guid isPermaLink="false">http://zou.lu/optimize-wordpress-themes-css-and-js-codes/</guid> <description><![CDATA[由于本人是个代码洁癖控+优化控，一旦确定使用某个主题以后，会彻底去优化他的代码（这时候从来没考虑过可读性）。 虽然现在的宽带1M、2M已经算不了什么，但是很多地方仍然使用512K甚至更低的网速，试想，一直小猫来访问你的网站，却要苦苦等待10多秒才能打开，也太那啥了吧，我曾经介绍过几个优化 WordPress 的文章： 优化你的 WordPress 之减少数据库查询次数（初级篇） 优化你的 WordPress 之精简 HTML 代码（进阶篇） 优化你的 WordPress 之减少数据库查询次数（中级篇） 优化你的 WordPress 之减少数据库查询次数（中级篇补充之 Object Cache） 最终的效果只是提高了 WordPress 的效率，在《优化你的 WordPress 之精简 HTML 代码（进阶篇）》一文中简单提到了要优化自己的HTML代码，作为一名超级代码洁癖控，怎么能容忍自己的 CSS 或者 JS 的代码的体积如此庞大，如此…… 所以，经过摸索，Showfom 小帅锅 决定彻底优化自己的 CSS 和 JS 代码，现在首页只加载了一个 CSS 和 JS，并且去除了多余的累赘的重复的代码，最终效果如下： //showfom.imgbed.com/v1/style.css 可以自行下载或者直接在 Firefox 中打开看效果，之前的体积有 14 KB 左右，经过妥善处理，现在体积只有 10KB 不到点，别小看这3、4KB，我想起了某个帅锅说过的一句话（其实你们知道是谁说的啦 哈哈）：“优化如同女人的乳沟，挤一挤还是可以再优化的。” 那么，需要用到什么工具呢？本人的优化系列的一大好处就是，几乎没有任何专业知识，我只传授方法，不传授原理（因为鄙人不才，自己也不是很懂专业知识），压缩CSS的终极利器就是：CSSTidy，这是一个开源程序，使用C++编写，作者也放出了PHP版本，下载地址在这里，你可以下载C++的源代码自己进行编译，也可以把PHP版上传到自己的空间。 默认中文的只有繁体，所以我特意为大家翻译好了中文，并且上传至我的空间，没有多余空间的朋友也可以享福了，地址： http://i.zou.lu/csstidy/ 简体中文版CSSTidy下载点这里。 [...]]]></description> <content:encoded><![CDATA[<p>由于本人是个代码洁癖控+优化控，一旦确定使用某个主题以后，会彻底去优化他的代码（这时候从来没考虑过可读性）。</p><p><span id="more-83"></span></p><p>虽然现在的宽带1M、2M已经算不了什么，但是很多地方仍然使用512K甚至更低的网速，试想，一直小猫来访问你的网站，却要苦苦等待10多秒才能打开，也太那啥了吧，我曾经介绍过几个优化 WordPress 的文章：</p><p><a title="优化你的 WordPress 之减少数据库查询次数（初级篇）" href="http://zou.lu/optimize-wordpress-database-query-rookie/">优化你的 WordPress 之减少数据库查询次数（初级篇）</a></p><p><a title="优化你的 WordPress 之精简 HTML 代码（进阶篇）" href="http://zou.lu/optimize-wordpress-themes-codes-normal/">优化你的 WordPress 之精简 HTML 代码（进阶篇）</a></p><p><a title="优化你的 WordPress 之减少数据库查询次数（中级篇）" href="http://zou.lu/optimize-wordpress-database-query-middle/">优化你的 WordPress 之减少数据库查询次数（中级篇）</a></p><p><a title="优化你的 WordPress 之减少数据库查询次数（中级篇补充之 Object Cache）" href="http://zou.lu/optimize-wordpress-database-query-middle-object-cache/">优化你的 WordPress 之减少数据库查询次数（中级篇补充之 Object Cache）</a></p><p>最终的效果只是提高了 <strong>WordPress</strong> 的效率，在《<a href="http://zou.lu/optimize-wordpress-themes-codes-normal/">优化你的 WordPress 之精简 HTML 代码（进阶篇）</a>》一文中简单提到了要优化自己的HTML代码，作为一名超级代码洁癖控，怎么能容忍自己的 <strong>CSS </strong>或者 <strong>JS </strong>的代码的体积如此庞大，如此……</p><p>所以，经过摸索，<strong>Showfom 小帅锅 </strong>决定彻底优化自己的 <strong>CSS </strong>和<strong> JS</strong> 代码，现在首页只加载了一个 <strong>CSS</strong> 和<strong> JS</strong>，并且去除了多余的累赘的重复的代码，最终效果如下：</p><p><a title="V1 模板的 CSS" href="//showfom.imgbed.com/v1/style.css">//showfom.imgbed.com/v1/style.css</a></p><p>可以自行下载或者直接在 <strong>Firefox </strong>中打开看效果，之前的体积有 <strong>14 KB</strong> 左右，经过妥善处理，现在体积只有<strong> 10KB</strong> 不到点，别小看这<strong>3、4KB</strong>，我想起了某个帅锅说过的一句话（其实你们知道是谁说的啦 哈哈）：“优化如同女人的乳沟，挤一挤还是可以再优化的。”</p><p>那么，需要用到什么工具呢？本人的优化系列的一大好处就是，几乎没有任何专业知识，我只传授方法，不传授原理（因为鄙人不才，自己也不是很懂专业知识），压缩<strong>CSS</strong>的终极利器就是：<strong>CSSTidy</strong>，这是一个开源程序，使用<strong>C++</strong>编写，<a title="CssTidy作者" href="http://csstidy.sourceforge.net/contact.php" target="_blank">作者</a>也放出了PHP版本，下载地址在<a title="CSSTidy下载" href="http://csstidy.sourceforge.net/download.php" target="_blank">这里</a>，你可以下载<strong>C++</strong>的源代码自己进行编译，也可以把<strong>PHP版</strong>上传到自己的空间。</p><p>默认中文的只有繁体，所以我特意为大家翻译好了中文，并且上传至我的空间，没有多余空间的朋友也可以享福了，地址：</p><p><a title="CSSTidy 1.3" href="http://i.zou.lu/csstidy/">http://i.zou.lu/csstidy/</a></p><p>简体中文版<strong>CSSTidy</strong>下载点<a title="CSSTidy 简体中文版下载" href="http://www.uushare.com/user/showfom/file/1837832" target="_blank">这里</a>。</p><p>使用方法，进入 <a title="CSSTidy 1.3" href="//showfom.imgbed.com/csstidy/">//showfom.imgbed.com/csstidy/</a> ，然后复制你的<strong>CSS代码</strong>，要稍微压缩的话直接点击执行，要最大化压缩（不在乎可读可修改性）的话，选择右边的压缩程度为最高，如图（以小众软件的<strong>CSS</strong>作为例子）：</p><p><a href="//showfom.imgbed.com/WordPressCSSJS_5F4/image.png" class="highslide-image" onclick="return hs.expand(this);"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）" src="//showfom.imgbed.com/WordPressCSSJS_5F4/image_thumb.png" border="0" alt="优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）" width="244" height="150" /></a></p><p>点击执行以后，看页面下方，会输出精简但是并不阉割的CSS代码：</p><p><a href="//showfom.imgbed.com/WordPressCSSJS_5F4/image_3.png" class="highslide-image" onclick="return hs.expand(this);"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）" src="//showfom.imgbed.com/WordPressCSSJS_5F4/image_thumb_4.png" border="0" alt="优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）" width="244" height="58" /></a></p><p>我们可以看到，原来<strong>21.934KB</strong>的<strong>CSS</strong>，可以精简到<strong>13.518KB</strong>，压缩比率:<strong> 38.4%</strong>，太帅了。</p><p>然后把精简过的 <strong>CSS </strong>复制到后台 &gt; 主题 &gt; 编辑 &gt; <strong>Style.css</strong></p><p>切记，除非和我一样，把样式放到单独的文件夹然后头部引用的CSS也是放在其他文件夹，那么，<strong>WordPress </strong>主题的 <strong>Style.css</strong> 必须满足头部信息的完整，就是前面几行注释一定得存在，否则读取不了主题就完了。</p><p>比如，小众软件这个<strong>CSS</strong>前面几行注释：</p><pre>/*
Theme Name: DeepBlue fix
Author URI: http://www.nathanrice.net/
Version: 1.0
Author: Nathan Rice
Description: DeepBlue is a free theme by &lt;a href="http://www.dailyblogtips.com/"&gt;Daily Blog Tips&lt;/a&gt;.
The CSS/XHTML is released under GPL:

http://www.opensource.org/licenses/gpl-license.php

*/</pre><p>必须存在，意思就是说，精简过的 <strong>CSS</strong> 代码中，把注释全部删除了，这几行得手工加在最前面，否则 WordPress 会读取不了主题。</p><p><strong>OK</strong>，<strong>CSS</strong>精简完毕，那么，如何再Gzip之，使得传输的时候再次压缩，不断压缩减小体积才是我们的目的 <img src='/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> ，这就得启动<strong> Gzip</strong> 功能，以前也介绍过，像 <strong>WP Super Cache</strong>、<strong>Hyper Cache</strong> 这些插件里自带了<strong> Gzip 功能</strong>，假如不用插件的话，可以用这几篇文章的方法</p><p><a title="完美启用Gzip压缩JS、CSS" href="http://www.life-studio.cn/compress-js-and-css-with-gzip.html">完美启用Gzip压缩JS、CSS</a></p><p><a title="Wordpress 提速之 Gzip 压缩" href="http://www.xiaorsz.com/wordpress-gzip-compression-improve-the-speed/" target="_blank">WordPress 提速之 Gzip 压缩</a></p><p><a title="Wordpress之终极Gzip兼容IE6" href="http://www.life-studio.cn/the-best-gzip-for-wordpress.html">WordPress之终极Gzip兼容IE6</a></p><p><a title="给 WordPress 开启 Gzip 功能" href="http://www.life-studio.cn/turn-on-gzip-for-wordpress.html" target="_blank">给 WordPress 开启 Gzip 功能</a></p><p>======</p><p>不但 <strong>CSS</strong> 可以这样压缩，<strong>JS</strong> 也同样可以，推荐在线压缩JS的网站：<a title="//showfom.imgbed.com/jsmin/" href="//showfom.imgbed.com/jsmin/">//showfom.imgbed.com/jsmin/</a>，来自 <a title="JS Minifier javascript" href="http://www.crockford.com/javascript/jsmin.html" target="_blank">JS Minifier javascript</a>，英文版在这里：<a title="http://fmarcia.info/jsmin/test.html" href="http://fmarcia.info/jsmin/test.html">http://fmarcia.info/jsmin/test.html</a> 中文版在这里： <a title="//showfom.imgbed.com/jsmin/" href="//showfom.imgbed.com/jsmin/">//showfom.imgbed.com/jsmin/</a></p><p><strong>PS：</strong>谨慎使用超级压缩（<small><strong>Agressive</strong></small>），一般推荐普通压缩（<small><strong>Conservative</strong></small>）即可，就是默认的那个，复制你的js代码到框框里，然后点击<strong>JSMin压缩</strong>即可。</p><p>同样，<strong>JS</strong> 和 <strong>CSS</strong> 一个道理，也可以通过 <strong>Gzip </strong>近一步压缩，这里我就不多介绍了。另外<a href="http://dean.edwards.name/packer/">这里</a>还有一个压缩 <strong>JS</strong> 的网站</p><p><strong>再次PS：</strong>优化得有针对性，针对某个网站某个博客优化才是硬道理，虽然每个网站的代码不通用，但是优化的原理都是一样滴，今天就不推荐博客和推友了。</p><h2  class="related_post_title">相关文章</h2><ul class="related_post"><li><a href="http://zou.lu/optimize-wordpress-themes-html-codes/" title="优化你的 WordPress 之精简全站 HTML 代码（终极篇）">优化你的 WordPress 之精简全站 HTML 代码（终极篇）</a> (90)</li><li><a href="http://zou.lu/optimize-wordpress-database-query-middle-object-cache/" title="优化你的 WordPress 之减少数据库查询次数（中级篇补充之 Object Cache）">优化你的 WordPress 之减少数据库查询次数（中级篇补充之 Object Cache）</a> (43)</li><li><a href="http://zou.lu/optimize-wordpress-database-query-middle/" title="优化你的 WordPress 之减少数据库查询次数（中级篇）">优化你的 WordPress 之减少数据库查询次数（中级篇）</a> (30)</li><li><a href="http://zou.lu/optimize-wordpress-themes-codes-normal/" title="优化你的 WordPress 之精简 HTML 代码（进阶篇）">优化你的 WordPress 之精简 HTML 代码（进阶篇）</a> (32)</li><li><a href="http://zou.lu/optimize-wordpress-database-query-rookie/" title="优化你的 WordPress 之减少数据库查询次数（初级篇）">优化你的 WordPress 之减少数据库查询次数（初级篇）</a> (28)</li><li><a href="http://zou.lu/use-cook-free-domain-for-your-wordpress/" title="提高 WordPress 速度之独立域名图床">提高 WordPress 速度之独立域名图床</a> (160)</li><li><a href="http://zou.lu/wpjam/" title="WordPress Jam &#8211; WP 建站服务一条龙">WordPress Jam &#8211; WP 建站服务一条龙</a> (63)</li><li><a href="http://zou.lu/mobilepress-themes-fixed/" title="MobilePress 主题汉化并修改">MobilePress 主题汉化并修改</a> (73)</li><li><a href="http://zou.lu/private-themes/" title="换上私人主题 + 清理友链">换上私人主题 + 清理友链</a> (187)</li><li><a href="http://zou.lu/chinese-beauties-in-wordpress-ii/" title="WordPress 中文界的美女们（第二期，有照片）">WordPress 中文界的美女们（第二期，有照片）</a> (309)</li></ul><hr /><div style="padding: 5px 10px; background: rgb(243, 245, 252) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"><p>© from <a href="//zou.lu/?from=feed">走点路博客</a>, 2009/07/28. | <a href="http://zou.lu/optimize-wordpress-themes-css-and-js-codes/">优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）</a> | <a href="http://zou.lu/optimize-wordpress-themes-css-and-js-codes/#comments">79 只留言鸟</a> <br /> Tags： <a href="http://zou.lu/tags/wordpress/" rel="tag">WordPress</a>, <a href="http://zou.lu/tags/wordpress%e4%bc%98%e5%8c%96/" rel="tag">WordPress优化</a> | <a href="//zou.lu/?p=83">Link</a> | <a href="http://zi.mu/domain"><font color="red">.me 域名全国最低价，首年仅需40元，续费130元促销中！</font></a></p></div>]]></content:encoded> <wfw:commentRss>http://zou.lu/optimize-wordpress-themes-css-and-js-codes/feed/</wfw:commentRss> <slash:comments>79</slash:comments> </item> <item><title>优化你的 WordPress 之减少数据库查询次数（中级篇补充之 Object Cache）</title><link>http://zou.lu/optimize-wordpress-database-query-middle-object-cache/</link> <comments>http://zou.lu/optimize-wordpress-database-query-middle-object-cache/#comments</comments> <pubDate>Mon, 25 May 2009 09:05:17 +0000</pubDate> <dc:creator>Showfom</dc:creator> <category><![CDATA[WordPress]]></category> <category><![CDATA[WordPress优化]]></category> <category><![CDATA[WordPress插件]]></category><guid isPermaLink="false">http://zou.lu/optimize-wordpress-database-query-middle-object-cache/</guid> <description><![CDATA[在 《优化你的 WordPress 之减少数据库查询次数（中级篇）》 一文中，提到了使用 DB Cache 来减少 WordPress 的php查询次数，本来这是一件好事，但是通过两天的测试（我这个小博客+两个流量较大的博客），发现 DB Cache 对评论的查询次数处理不是很好，每个文章页面假如评论过多，还是会产生额外的20、30次查询，所以，再次启用一个不算插件的插件 – Object Cache。 本文只介绍 Object Cache ，哎，我真是个花心的人，前天还把 DB Cache 爱的死去活来的，今天就被 Object Cache 这个小妖精给迷惑了。 严格意义上说，Object Cache 不是一个 WordPress 插件 ，他的全称是 File-Based Object Caching ， 作者是 Mahmoud Al-Qudsi ，这老外的名字取的，默罕默德，我还阿尔法特呢…… 但是 Object Cache 能有效减少 WordPress 的 php查询次数 ，而且针对每单篇文章更有效，引用一句广告台词，自从用了 Object Cache，咱博客腰不酸了，腿不痛了，一下次高潮达到5次，还不嫌累哦！ 下载地址在这里：Download &#124; 大陆镜像 着重讲讲安装方法： Object [...]]]></description> <content:encoded><![CDATA[<p>在 <a title="优化你的 WordPress 之减少数据库查询次数（中级篇）" href="http://zou.lu/optimize-wordpress-database-query-middle/">《优化你的 WordPress 之减少数据库查询次数（中级篇）》</a> 一文中，提到了使用 <strong></strong><a class="external" href="http://wordpress.org/extend/plugins/db-cache/"><strong>DB Cache</strong></a> 来减少 <a title="WordPress" href="http://zou.lu/wordpress/"><strong>WordPress</strong></a> 的<strong>php查询次数</strong>，本来这是一件好事，但是通过两天的测试（我这个小博客+两个流量较大的博客），发现 <strong>DB Cache</strong> 对评论的查询次数处理不是很好，每个文章页面假如评论过多，还是会产生额外的20、30次查询，所以，再次启用一个不算插件的插件 – <strong>Object Cache</strong>。</p><p><span id="more-46"></span></p><p>本文只介绍 <strong>Object Cache</strong> ，哎，我真是个花心的人，前天还把 <strong>DB Cache</strong> 爱的死去活来的，今天就被 <strong>Object Cache</strong> 这个小妖精给迷惑了。</p><p>严格意义上说，Object Cache 不是一个 <strong>WordPress 插件</strong> ，他的全称是 <a class="external" href="http://neosmart.net/dl.php?id=14">File-Based Object Caching</a> ， 作者是 <a class="external" href="http://neosmart.net/blog/">Mahmoud Al-Qudsi</a> ，这老外的名字取的，默罕默德，我还阿尔法特呢……</p><p>但是 <strong>Object Cache</strong> 能有效减少 <strong>WordPress</strong> 的 <strong>php查询次数</strong> ，而且针对每单篇文章更有效，引用一句广告台词，自从用了 <strong>Object Cache</strong>，咱博客腰不酸了，腿不痛了，一下次高潮达到5次，还不嫌累哦！</p><p>下载地址在这里：<a class="external" title="Download File-Based Caching for WordPress 1.0" href="http://neosmart.net/dl.php?id=14">Download</a> | <a class="external" title="Download Object Cache" href="http://www.uushare.com/user/showfom/file/1633722">大陆镜像</a></p><p><strong>着重讲讲安装方法：</strong></p><blockquote><p><strong>Object Cache</strong> 需要手工安装，首先，上传 <strong>object-cache.php</strong> 至 <strong>wp-content</strong> 目录，然后在 <strong>wp-content</strong> 目录新建一个文件夹 <strong>cache</strong> （和 <strong>WP Super Cache</strong> 那个文件夹一样），需要有写入权限（777、755等）。</p></blockquote><p>然后修改你博客根目录的 <strong>wp-config.php</strong></p><p>加上这么一行：</p><blockquote><p>// Enable the WordPress Object Cache，这是注释:<br /> define('ENABLE_CACHE', true);</p></blockquote><p><strong>OK</strong>，看看 <strong>wp-content/cache</strong> 文件夹里有没有多出一些缓存文件，假如多出了，就说明安装成功，看看首页的效果吧：</p><blockquote><p>5 queries in 0.619 seconds.</p></blockquote><p>尽管只减少了一次查询，还是有所收获哈哈</p><blockquote><p>其实最主要还是看你文章页面的查询，以前我都有20、30次，现在只有9、10次左右了，这个效果才是最明显的！</p></blockquote><p>貌似默罕默德先生还有几个加速 <strong>WordPress</strong> 的插件，到时候再去测试测试，难道 <strong>Mr Mahmoud</strong> 是 <strong>WordPress 缓存夜总会</strong>的妈妈桑？不过提供的小姐质量确实不错！</p><ol><li><a class="external" href="http://neosmart.net/dl.php?id=12">XCache for WordPress</a></li><li><a class="external" href="http://neosmart.net/dl.php?id=13">eAccelerator for WordPress</a></li><li><a class="external" href="http://txfx.net/files/wordpress/apc-object-cache.phps">APC for WordPress</a></li><li><a class="external" href="http://ryan.wordpress.com/2005/12/23/memcached-backend/">Memcached for WordPress</a></li></ol><p>PS：与本文无关的几句话</p><p>发现 WordPress 中国用户里对猫的感情特别深厚，我知道的就有：</p><p><a class="external" title="Maozz" href="http://maozz.com/">Maozz</a> <a class="external" title="LeeHow" href="http://leehow.com/">LeeHow</a> <a class="external" title="Maoxmao" href="http://www.maoxmao.com/">Maoxmao</a> <a class="external" title="OOXX" href="http://ooxx.me/">OOXX</a> 等等，当然 <a class="external" title="煎蛋" href="http://jandan.net/">煎蛋</a> 里也都是猫迷，囧，今日就发两张猫猫的图片吧，猫猫很可爱的。</p><p><a href="//showfom.imgbed.com/WordPressObjectCache_EFF0/image.png" class="highslide-image" onclick="return hs.expand(this);"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="我是猫咪" src="//showfom.imgbed.com/WordPressObjectCache_EFF0/image_thumb.png" border="0" alt="我是猫咪" width="244" height="209" /></a> <a href="//showfom.imgbed.com/WordPressObjectCache_EFF0/image_3.png" class="highslide-image" onclick="return hs.expand(this);"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="我是猫咪" src="//showfom.imgbed.com/WordPressObjectCache_EFF0/image_thumb_3.png" border="0" alt="我是猫咪" width="194" height="208" /></a> <a href="//showfom.imgbed.com/WordPressObjectCache_EFF0/image_4.png" class="highslide-image" onclick="return hs.expand(this);"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="我是猫咪" src="//showfom.imgbed.com/WordPressObjectCache_EFF0/image_thumb_4.png" border="0" alt="我是猫咪" width="182" height="207" /></a> <a href="//showfom.imgbed.com/WordPressObjectCache_EFF0/image_5.png" class="highslide-image" onclick="return hs.expand(this);"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="我是老鼠" src="//showfom.imgbed.com/WordPressObjectCache_EFF0/image_thumb_5.png" border="0" alt="我是老鼠" width="233" height="176" /></a></p><p><a href="//showfom.imgbed.com/WordPressObjectCache_EFF0/LPNZH3ENGU61N3OV8F6.jpg" class="highslide-image" onclick="return hs.expand(this);"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="我是猫猫" src="//showfom.imgbed.com/WordPressObjectCache_EFF0/LPNZH3ENGU61N3OV8F6_thumb.jpg" border="0" alt="我是猫猫" width="48" height="48" /></a> 本文到此结束，这几天得休息休息，哎，昨晚失眠……</p><h2  class="related_post_title">相关文章</h2><ul class="related_post"><li><a href="http://zou.lu/optimize-wordpress-database-query-middle/" title="优化你的 WordPress 之减少数据库查询次数（中级篇）">优化你的 WordPress 之减少数据库查询次数（中级篇）</a> (30)</li><li><a href="http://zou.lu/mobilepress-themes-fixed/" title="MobilePress 主题汉化并修改">MobilePress 主题汉化并修改</a> (73)</li><li><a href="http://zou.lu/comment-info-detector/" title="WordPress 显示留言者信息插件 &#8211; Comment Info Detector">WordPress 显示留言者信息插件 &#8211; Comment Info Detector</a> (258)</li><li><a href="http://zou.lu/careful-about-wordpress-plugins/" title="千里之堤溃于蚁穴 &#8211; 慎用 WordPress 插件">千里之堤溃于蚁穴 &#8211; 慎用 WordPress 插件</a> (135)</li><li><a href="http://zou.lu/comments-text-replace/" title="WordPress 精简版评论文明用语插件">WordPress 精简版评论文明用语插件</a> (118)</li><li><a href="http://zou.lu/optimize-wordpress-themes-html-codes/" title="优化你的 WordPress 之精简全站 HTML 代码（终极篇）">优化你的 WordPress 之精简全站 HTML 代码（终极篇）</a> (90)</li><li><a href="http://zou.lu/optimize-wordpress-themes-css-and-js-codes/" title="优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）">优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）</a> (79)</li><li><a href="http://zou.lu/wordpress-plugins-i-used/" title="我使用的 WordPress 插件">我使用的 WordPress 插件</a> (90)</li><li><a href="http://zou.lu/notes-for-wordpress-28-upgrading/" title="升级到 WordPress 2.8 以后要注意的事项">升级到 WordPress 2.8 以后要注意的事项</a> (61)</li><li><a href="http://zou.lu/auto-hishslide-wordpress-plugin/" title="Auto HighSlide &#8211; 真正自动增加 WordPress 的 HighSlide 图片效果插件">Auto HighSlide &#8211; 真正自动增加 WordPress 的 HighSlide 图片效果插件</a> (173)</li></ul><hr /><div style="padding: 5px 10px; background: rgb(243, 245, 252) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"><p>© from <a href="//zou.lu/?from=feed">走点路博客</a>, 2009/05/25. | <a href="http://zou.lu/optimize-wordpress-database-query-middle-object-cache/">优化你的 WordPress 之减少数据库查询次数（中级篇补充之 Object Cache）</a> | <a href="http://zou.lu/optimize-wordpress-database-query-middle-object-cache/#comments">43 只留言鸟</a> <br /> Tags： <a href="http://zou.lu/tags/wordpress/" rel="tag">WordPress</a>, <a href="http://zou.lu/tags/wordpress%e4%bc%98%e5%8c%96/" rel="tag">WordPress优化</a>, <a href="http://zou.lu/tags/wordpress%e6%8f%92%e4%bb%b6/" rel="tag">WordPress插件</a> | <a href="//zou.lu/?p=46">Link</a> | <a href="http://zi.mu/domain"><font color="red">.me 域名全国最低价，首年仅需40元，续费130元促销中！</font></a></p></div>]]></content:encoded> <wfw:commentRss>http://zou.lu/optimize-wordpress-database-query-middle-object-cache/feed/</wfw:commentRss> <slash:comments>43</slash:comments> </item> <item><title>优化你的 WordPress 之减少数据库查询次数（中级篇）</title><link>http://zou.lu/optimize-wordpress-database-query-middle/</link> <comments>http://zou.lu/optimize-wordpress-database-query-middle/#comments</comments> <pubDate>Sat, 23 May 2009 08:36:54 +0000</pubDate> <dc:creator>Showfom</dc:creator> <category><![CDATA[WordPress]]></category> <category><![CDATA[WordPress优化]]></category> <category><![CDATA[WordPress插件]]></category><guid isPermaLink="false">http://zou.lu/optimize-wordpress-database-query-middle/</guid> <description><![CDATA[本文介绍如何使用正确的插件来减少 WordPress 的数据库查询次数，效果可以看我首页底部： 6 queries in 0.611 seconds 好了，进入正文。 1、DB Cache 在 《优化你的 WordPress 之减少数据库查询次数（初级篇）》 一文中，我提到了使用 WP Widget Cache 来减少侧边栏sidebar 的查询，但是，对没有使用 widget，或者不喜欢使用 widget 的朋友，WP Widget Cache 插件就没用了，所以，再介绍一款减少数据库查询次数的终极宝剑 —— DB Cache 看看作者的介绍吧： This plugin caches every database query with given lifetime. It is much faster than other html caching plugins and uses less disk space for [...]]]></description> <content:encoded><![CDATA[<p>本文介绍如何使用正确的插件来减少 <a title="WordPress" href="http://zou.lu/wordpress/">WordPress</a> 的数据库查询次数，效果可以看我首页底部：</p><pre>6 queries in 0.611 seconds</pre><p>好了，进入正文。</p><p><span id="more-45"></span></p><p><font color="#ff8040" size="3"><strong>1、</strong></font><a class="external" title="DB Cache" href="http://wordpress.org/extend/plugins/db-cache/"><font color="#ff8040" size="3"><strong>DB Cache</strong></font></a></p><p>在 <a href="http://zou.lu/optimize-wordpress-database-query-rookie/">《优化你的 WordPress 之减少数据库查询次数（初级篇）》</a> 一文中，我提到了使用 <a class="external" href="http://wordpress.org/extend/plugins/wp-widget-cache/"><strong>WP Widget Cache</strong></a> 来减少侧边栏<strong>sidebar</strong> 的查询，但是，对没有使用 <strong>widget</strong>，或者不喜欢使用 <strong>widget</strong> 的朋友，<a class="external" href="http://wordpress.org/extend/plugins/wp-widget-cache/"><strong>WP Widget Cache</strong></a> 插件就没用了，所以，再介绍一款减少数据库查询次数的终极宝剑 —— <a title="DB Cache" href="http://wordpress.org/extend/plugins/db-cache/"><strong>DB Cache</strong></a></p><p>看看作者的介绍吧：</p><blockquote><p>This plugin caches every database query with given lifetime. It is much faster than other html caching plugins and uses less disk space for caching.</p><p>I think you've heard of <a class="external" href="http://wordpress.org/extend/plugins/wp-cache/"><strong>WP-Cache</strong></a> or <a class="external" href="http://wordpress.org/extend/plugins/wp-super-cache/"><strong>WP Super Cache</strong></a>, they are both top plugins for WordPress, which make your site faster and responsive. Forget about them - with DB Cache your site will work much faster and will use less disk space for cached files. Your visitors will always get actual information in sidebars and server CPU loads will be as low as posible.</p></blockquote><p>简单淫荡翻译一下：</p><p>这个插件能长期缓存所有（真的吗？怀疑）数据库查询。比那些狗屁鸡巴HTML缓存插件快多了，而且占用的空间更小。</p><blockquote><p>我想你可能听说过 <a class="external" href="http://wordpress.org/extend/plugins/wp-cache/"><strong>WP-Cache</strong></a> 或者 <a class="external" href="http://wordpress.org/extend/plugins/wp-super-cache/"><strong>WP Super Cache</strong></a> ，他们都是 <strong>WordPress</strong> 的热门插件，能使你的博客访问速度更快。忘了她们吧，直接投入偶的怀抱，相信我，在你的博客用 <strong>DB Cache</strong> 插件，一定会更快，缓存空间更小。当然，访客能获取实时的侧边栏，<strong>CPU 占有率</strong>也会很小。</p></blockquote><p>再次用最淫荡的语言阐述一下：</p><blockquote><p>大家好，我是 <strong>Miss DB Cache</strong> ，在 <strong>WordPress</strong> 夜总会工作，他们叫我性感小D，哎，都是那些臭男人，尤其是那个叫 <strong>Showfom</strong> 的家伙，每次都让人家很快进入高潮，哎呀，坏死了嘛。我有两个小姐妹，据说是双胞胎哦（要双飞吗？坏死了你。） <strong>Miss WP-Cache</strong> 和 <strong>Miss WP Super Cache</strong> 不过他们负责记住客人的相貌，而我能记住客人 的内心世界。每次最先达到高潮的总是人家，这位大哥，要不要试试？不用带套哦。</p><p>PS：纯属虚构，望路过者笑之……</p></blockquote><p><strong>DB Cache</strong> 能缓存尽可能多的 <strong>php查询</strong> ，官方解释是全部，我的解释是放屁。这不是一个 <strong>WP Widget Cache</strong> 就能搞定的，使用效果及其明显，尤其是首页，因为不用查询过多的评论，文章页面由于要查询过多的评论（前提是你的文章够热门），所以效果没首页那么明显。</p><p><strong>DB Cache</strong> 的安装使用方法很简单，上传后台激活，然后选定 <strong>Enable</strong> 即可（如图）</p><p><a href="//showfom.imgbed.com/WordPress_E160/image.png" class="highslide-image" onclick="return hs.expand(this);"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="//showfom.imgbed.com/WordPress_E160/image_thumb.png" width="244" height="82" /></a></p><p>记得 <strong>wp-content 文件夹 </strong>要有<strong>写入</strong>的权限，比如 666 755 777 ，这个我不是很懂，所以犯过一些错误哎。</p><p>默认会在<strong>&lt;?php wp_footer() ?&gt;</strong> 中写入一句，比如</p><pre>&lt;!-- Generated in 0.199 seconds. Made 15 queries to database and 8 cached queries. Memory used - 14.86MB --&gt;
&lt;!-- Cached by DB Cache --&gt;</pre><p>当然，我是不会用的，所以清空<strong>选项</strong>里 <strong>Load stats template</strong> 里的那句话即可。</p><p>效果很明显吧？</p><p>下载地址：<a class="external" title="DB Cache" href="http://wordpress.org/extend/plugins/db-cache/">http://wordpress.org/extend/plugins/db-cache/</a></p><p>&#160;</p><p><font color="#ff8040" size="3"><strong>2、</strong></font><a class="external" title="WP Widget Cache" href="http://wordpress.org/extend/plugins/wp-widget-cache/"><font color="#ff8040" size="3"><strong>WP Widget Cache</strong></font></a></p><p>对于喜欢使用 <strong>Widget </strong>的朋友，比如 <strong><a href="http://zou.lu/">Showfom</a></strong> 这个自恋的家伙，当然可以配合 <strong>WP Widget Cache</strong> 一起使用，效果良好，是出家写博的必备良药。</p><p>由于 <strong>WP Widget Cache</strong> 在 <a href="http://zou.lu/optimize-wordpress-database-query-rookie/"><strong>《优化你的 WordPress 之减少数据库查询次数（初级篇）》</strong></a> 一文中已经介绍使用，所以这里不多做介绍了。</p><p>直接上传后台激活启用即可，当然要用自己的 <strong>Widget</strong> ，否则缓存没作用</p><p>下载地址：<a class="external" title="WP Widget Cache" href="http://wordpress.org/extend/plugins/wp-widget-cache/">http://wordpress.org/extend/plugins/wp-widget-cache/</a></p><p>&#160;</p><p><font color="#ff8040" size="3"><strong>3、</strong></font><a class="external" title="WP Super Cache" href="http://wordpress.org/extend/plugins/wp-super-cache/"><font color="#ff8040" size="3"><strong>WP Super Cache</strong></font></a></p><p><a class="external" href="http://wordpress.org/extend/plugins/wp-cache/"><strong>WP-Cache</strong></a> 的升级版，所以就忘记 <a class="external" href="http://wordpress.org/extend/plugins/wp-cache/"><strong>WP-Cache</strong></a> 吧。</p><p>基本上国内几个大的博客都使用 WP Super Cache ，优点很多，确实很快。我对 php 还不是很了解，原理也不是很懂，所以最简单的方法就是用我的那几个大流量的博客进行试验，结果发现 WP Super Cache 效果确实好，但是缺点是要改写 .htaccess ，对 Niginx 的童鞋，要自己去搜索 WP Super Cache for Nginx 的代码，而且目录权限要设置，有点高级插件的味道，但是确实不是吹的，速度一流，推荐大站和高手使用。</p><p>下载地址：<a class="external" title="WP Super Cache" href="http://wordpress.org/extend/plugins/wp-super-cache/">http://wordpress.org/extend/plugins/wp-super-cache/</a></p><p>&#160;</p><p><font color="#ff8040" size="3"><strong>4、</strong></font><a class="external" title="Hyper Cache" href="http://wordpress.org/extend/plugins/hyper-cache/"><font color="#ff8040" size="3"><strong>Hyper Cache</strong></font></a></p><p>Hyper Cache 我使用了好几个月了，速度比 WP Super Cache 要慢上那么一点点，不过总体来说差不多，肉眼看不出哈哈。缺点嘛，用了以后不记录 cookies 每次评论都要再次输入，对一些交流性很强的互动型的博客不适用，当然有方法：<a href="http://hellobmw.com/archives/cookie-validation-for-static-wordpress.html">WordPress 完全静态化后的 cookie 验证</a>，只是我这个菜鸟用了半天还是不对，所以，我只对两个互动性不太大但是访问量较大的博客使用了 Hyper Cache ，嗯，速度也是一流的。</p><p>下载地址：<a class="external" title="Hyper Cache" href="http://wordpress.org/extend/plugins/hyper-cache/">http://wordpress.org/extend/plugins/hyper-cache/</a></p><p>&#160;</p><p><font color="#ff8040" size="3"><strong>5、</strong></font><a class="external" title="COS-HTML-Cache" href="http://wordpress.org/extend/plugins/cos-html-cache/"><font color="#ff8040" size="3"><strong>COS-HTML-Cache</strong></font></a></p><p>江东童鞋写的，不过我一直没用，所以不好发表评论，国内用的人还是比较多的，推荐试试，直接生成 <strong>html</strong> 哦。</p><p>下载地址：<a class="external" title="COS-HTML-Cache" href="http://wordpress.org/extend/plugins/cos-html-cache/">http://wordpress.org/extend/plugins/cos-html-cache/</a></p><p>&#160;</p><p><font color="#ff8040" size="3"><strong>6、总结</strong></font></p><p>目前<a title="Showfom&#39;s Blog" href="http://zou.lu/">本博客</a>使用的情况是：<strong>WP Super Cache</strong></p><p>其中 <strong>DB Cache</strong> 和 <strong>WP Widget Cache</strong> 可以配合其他几个缓存插件使用，<strong>WP Super Cache</strong>、<strong>Hyper Cache</strong> 还有 <strong>COS-HTML-Cache</strong> 千万别混合使用，不然不只是 <strong>MJJ</strong> 的事情了……</p><p>&#160;</p><p><font color="#ff8040" size="3"><strong>7、申明</strong></font></p><p>对 <strong>php</strong> 我不是很在行，所有插件都是亲自测试体验加上四个眼睛加上 <strong>Firebug </strong>测试出来的结果，具体数据每个人情况不同就不写了，总是效果就是这样，如有异议，欢迎留言探讨，或许不久的将来，会出现高级篇哦。</p><p>&#160;</p><p><font color="#ff8040" size="3"><strong>8、为什么博主的技术类文章总是那么欠揍？</strong></font></p><p>淫荡的人生，需要解释吗？</p><h2  class="related_post_title">相关文章</h2><ul class="related_post"><li><a href="http://zou.lu/optimize-wordpress-database-query-middle-object-cache/" title="优化你的 WordPress 之减少数据库查询次数（中级篇补充之 Object Cache）">优化你的 WordPress 之减少数据库查询次数（中级篇补充之 Object Cache）</a> (43)</li><li><a href="http://zou.lu/mobilepress-themes-fixed/" title="MobilePress 主题汉化并修改">MobilePress 主题汉化并修改</a> (73)</li><li><a href="http://zou.lu/comment-info-detector/" title="WordPress 显示留言者信息插件 &#8211; Comment Info Detector">WordPress 显示留言者信息插件 &#8211; Comment Info Detector</a> (258)</li><li><a href="http://zou.lu/careful-about-wordpress-plugins/" title="千里之堤溃于蚁穴 &#8211; 慎用 WordPress 插件">千里之堤溃于蚁穴 &#8211; 慎用 WordPress 插件</a> (135)</li><li><a href="http://zou.lu/comments-text-replace/" title="WordPress 精简版评论文明用语插件">WordPress 精简版评论文明用语插件</a> (118)</li><li><a href="http://zou.lu/optimize-wordpress-themes-html-codes/" title="优化你的 WordPress 之精简全站 HTML 代码（终极篇）">优化你的 WordPress 之精简全站 HTML 代码（终极篇）</a> (90)</li><li><a href="http://zou.lu/optimize-wordpress-themes-css-and-js-codes/" title="优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）">优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）</a> (79)</li><li><a href="http://zou.lu/wordpress-plugins-i-used/" title="我使用的 WordPress 插件">我使用的 WordPress 插件</a> (90)</li><li><a href="http://zou.lu/notes-for-wordpress-28-upgrading/" title="升级到 WordPress 2.8 以后要注意的事项">升级到 WordPress 2.8 以后要注意的事项</a> (61)</li><li><a href="http://zou.lu/auto-hishslide-wordpress-plugin/" title="Auto HighSlide &#8211; 真正自动增加 WordPress 的 HighSlide 图片效果插件">Auto HighSlide &#8211; 真正自动增加 WordPress 的 HighSlide 图片效果插件</a> (173)</li></ul><hr /><div style="padding: 5px 10px; background: rgb(243, 245, 252) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"><p>© from <a href="//zou.lu/?from=feed">走点路博客</a>, 2009/05/23. | <a href="http://zou.lu/optimize-wordpress-database-query-middle/">优化你的 WordPress 之减少数据库查询次数（中级篇）</a> | <a href="http://zou.lu/optimize-wordpress-database-query-middle/#comments">30 只留言鸟</a> <br /> Tags： <a href="http://zou.lu/tags/wordpress/" rel="tag">WordPress</a>, <a href="http://zou.lu/tags/wordpress%e4%bc%98%e5%8c%96/" rel="tag">WordPress优化</a>, <a href="http://zou.lu/tags/wordpress%e6%8f%92%e4%bb%b6/" rel="tag">WordPress插件</a> | <a href="//zou.lu/?p=45">Link</a> | <a href="http://zi.mu/domain"><font color="red">.me 域名全国最低价，首年仅需40元，续费130元促销中！</font></a></p></div>]]></content:encoded> <wfw:commentRss>http://zou.lu/optimize-wordpress-database-query-middle/feed/</wfw:commentRss> <slash:comments>30</slash:comments> </item> <item><title>优化你的 WordPress 之精简 HTML 代码（进阶篇）</title><link>http://zou.lu/optimize-wordpress-themes-codes-normal/</link> <comments>http://zou.lu/optimize-wordpress-themes-codes-normal/#comments</comments> <pubDate>Mon, 11 May 2009 07:01:44 +0000</pubDate> <dc:creator>Showfom</dc:creator> <category><![CDATA[WordPress]]></category> <category><![CDATA[WordPress优化]]></category><guid isPermaLink="false">http://zou.lu/optimize-wordpress-themes-codes-normal/</guid> <description><![CDATA[真是不用不知道，一用吓一跳，今天看了 Lightbox 2 的代码才知道，需要用到 4 个 JS ，总共将近 200 KB……所以，我义无反顾地把 Lightbox 2 禁用，本文将以及其猥琐的语言简单描述如何精简你的 WordPress 模板。 1、Header.php 精简 很多插件都是需要加载 js 和 css 的，而且默认就直接放到了 &#60;?php wp_head(); ?&#62; 函数里，这样做只是为了适合大众的主题，在个性化打造、精简自己的 WordPress 主题时，完全可以把主题目录里的 header.php 中的 &#60;?php wp_head(); ?&#62; 删除，而采用自己添加 js 和 css 。 (PS:删除 &#60;?php wp_head(); ?&#62; 以后 All in One SEO 插件的 &#60;meta&#62; 关键词和描述功能将失去作用，可以自行  SEO ，WP-PostViews 也会失去作用，目前头大中……) 由于 HTML [...]]]></description> <content:encoded><![CDATA[<p>真是不用不知道，一用吓一跳，今天看了 <strong>Lightbox 2</strong> 的代码才知道，需要用到 <strong>4</strong> 个 <strong>JS </strong>，总共将近 200 KB……所以，我义无反顾地把 <strong>Lightbox 2</strong> 禁用，本文将以及其猥琐的语言简单描述如何精简你的 <strong><a href="http://zou.lu/wordpress/">WordPress</a></strong> 模板。</p><p><span id="more-36"></span></p><p><span style="color: #0080ff;"><strong>1、Header.php 精简</strong></span></p><p>很多插件都是需要加载 <strong>js</strong> 和 <strong>css</strong> 的，而且默认就直接放到了 <strong>&lt;?php wp_head(); ?&gt;</strong> 函数里，这样做只是为了适合大众的主题，在个性化打造、精简自己的 <strong>WordPress </strong>主题时，完全可以把主题目录里的 <strong>header.php</strong> 中的 <strong>&lt;?php wp_head(); ?&gt;</strong> 删除，而采用自己添加 <strong>js</strong> 和 <strong>css</strong> 。</p><p>(PS:删除<strong> </strong><strong>&lt;?php wp_head(); ?&gt; </strong>以后 <strong>All in One SEO</strong> 插件的<strong> &lt;meta&gt;</strong> 关键词和描述功能将失去作用，可以自行  <strong>SEO</strong> ，<strong>WP-PostViews</strong> 也会失去作用，目前头大中……)</p><p>由于 <strong>HTML</strong> 语言和大多数语言一样，采用的是自上而下的顺序，假如头部的 <strong>js</strong> 太大，那么访问者一开始就会花上几秒甚至十几秒钟的时间来加载你的 <strong>js</strong> 文件，同样适用 <strong>css</strong> 。那么，怎么精简呢？我的做法有五点：</p><p><span style="color: #ff0000;">1.别去用花哨功能的插件</span></p><p>比如上文提到的 <strong>Lightbox 2</strong>，启动这个插件，默认就会载入四个 js ，分别是</p><pre>/wp-includes/js/prototype.js（121KB）</pre><pre>/wp-includes/js/scriptaculous/wp-scriptaculous.js（2.6KB）</pre><pre>/wp-includes/js/scriptaculous/effects.js（38.1KB）</pre><pre>/wp-content/plugins/lightbox-2/lightbox.js（20.8KB）</pre><p>就为了这个华丽花哨的图片效果，就要载入近 <strong>200KB</strong> 的 <strong>js</strong> 文件，值得么？访客愿意花上好几秒钟先把这四个<strong> js</strong> 加载完毕再等待正文的出现么？所以我的做法是直接把 <strong>Lightbox 2</strong> 禁用，当然，假如你非得使用，那么，请把上述四个 <strong>js</strong> 文件放到 <strong>footer.php</strong> ，别忘了还有一个 <strong>css</strong> ，下文会提及。</p><p><span style="color: #ff0000;">2.把 js 放在 footer.php 而不是 header.php</span></p><p>除了必要的几个需要加载在头部的文件（比如 <strong>css</strong> ），其余的实际上都可以放在底部，这样不但美观，而且 <strong>js</strong> 放在底部是不会影响整个网站的，在整个网页加载完毕以后照样完整显示效果，当然，这里必须注意次序问题，有些 <strong>js</strong> 的次序千万别颠倒，否则就没法使用，比如本站使用的 <strong><a href="http://zou.lu/sweet-titles-wordpress-plugin/">Sweet Titles</a></strong> 里的两个 <strong>js</strong> 文件的次序。</p><p><span style="color: #ff0000;">3.使用 Google Code 储存你的js</span></p><p>你的服务器带宽再怎么好，总比不上 <strong>Google </strong>吧？所以，个人用户推荐把一些 js 文件直接放在 <a href="http://code.google.com/">http://code.google.com/</a> 当中，比如，你很想使用 <strong>Lightbox 2</strong>，那么我已经帮你上传好这四个 <strong>js</strong> ，只要在 <strong>footer.php</strong> 的 <strong>&lt;/body&gt;</strong> 前插入</p><pre>&lt;script type="text/javascript" src='http://showfom.googlecode.com/files/prototype.js?ver=1.6"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="http://showfom.googlecode.com/files/wp-scriptaculous.js?ver=1.8.0"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="http://showfom.googlecode.com/files/effects.js?ver=1.8.0"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="http://showfom.googlecode.com/files/lightbox.js?ver=1.8"&gt;&lt;/script&gt;</pre><p>然后加载一个 <strong>css</strong> 效果，比如</p><pre>&lt;link rel="stylesheet" href="/wp-content/plugins/lightbox-2/Themes/Dark Grey/lightbox.css" type="text/css" media="screen" /&gt;</pre><p>然后启动 <strong>Lightbox 2</strong> 插件，记得把 <strong>header.php</strong> 里的 <strong>&lt;?php wp_head(); ?&gt;</strong> 删除</p><p><span style="color: #ff0000;">4.合并你的 js 和 css</span></p><p>合并 <strong>css </strong>很简单，你可以通过查看源代码，把一些 <strong>.css</strong> 结尾的文件内容全部复制到主题目录的 <strong>style.css</strong> ，当然还有一些直接输出 <strong>css</strong> 的插件，比如 <strong>WordPress Thread Comments</strong> ，把直接输出的 <strong>css </strong>也一起复制到 <strong>style.css</strong> 中，尽量保持整个页面只加载一个 <strong>css</strong> ，不但提高了效率，而且还可以一起压缩 <strong>css</strong> ，何乐而不为？</p><p>合并 js 就有点麻烦，因为必须考虑次序问题，你可以使用<a href="http://zhiqiang.org/blog/420.html">阅微堂提供的方法</a> （一下内容来自 <a href="http://www.gexiaofei.com/20071019205.html">Gexiaofei.com</a>）：</p><p>建立一个新的 <strong>all.js.php</strong> 文件，内容是：</p><pre>&lt;?php

require_once('&amp;#30446;&amp;#24405;/wp-blog-header.php' ) ;

include ("/a.js" ) ;

include ("/b.js" ) ;

?&gt;</pre><p>就是将 <strong>header.php</strong> 里面的那些 <strong>js </strong>文件都<strong> include</strong> 到 <strong>all.js.php</strong> ，然后在<strong> header</strong> 里面包含 <strong>all.js.php</strong> 文件即可：</p><pre>&lt;script xsrc="/all.js.php" type="text/javascript" /&gt;</pre><p><span style="color: #ff0000;">5.使用 gzip 进一步压缩</span></p><p>这个就不做多少介绍，<strong>Nginx</strong> 默认配置就开通了 <strong>gzip</strong> ，假如是 <strong>Apache</strong> 的主机，可以通过修改 <strong>.htaccess</strong> 或 使用 <strong><a href="http://wordpress.org/extend/plugins/hyper-cache/">Hyper Cache</a></strong>、<strong><a href="http://wordpress.org/extend/plugins/wp-super-cache/">WP Super Cache</a></strong> 等插件辅助使用 <strong>gzip</strong> 功能，网上文章一大把，自己 <strong>Google</strong> 学习之。</p><p>当然，还可以直接通过精简代码压缩 <strong>css</strong> 和 <strong>js </strong>，做到最大化精简，参考文章有：</p><p><a title="CSS 压缩与优化工具" href="http://www.osxcn.com/css/css-compressor.html">CSS 压缩与优化工具</a></p><p><a title="Good Online JavaScript Encoding &amp; CSS Compression tools" href="http://blog.rvdavid.net/good-online-javascript-encoding-css-compression-tools/">Good Online JavaScript Encoding &amp; CSS Compression tools</a></p><p>OK，头部的信息就尽量很简洁了。接下来说说底部</p><p><strong><span style="color: #0080ff;">2、Footer.php 的精简</span></strong></p><p>和头部一样，通常大多数主题会在 <strong>footer.php</strong> 增加一个 <strong>&lt;?php wp_footer(); ?&gt;</strong> 以适应各种插件，比如 <a title="WordPress.com Stat" href="http://wordpress.org/extend/plugins/stats/"><strong>WordPress.com Stat</strong></a> 插件就是把统计代码直接加在<strong> &lt;?php wp_footer(); ?&gt;</strong> 里。</p><p>但是这么做就会增加一次数据库查询，所以，我的做法就是直接删除 <strong>&lt;?php wp_footer(); ?&gt;</strong> 。</p><p>而且还可以参考上面的方法，把一些没必要开头就加载的 js 文件放在头部，放到 <strong>footer.php</strong> 是个很好的选择，而且，尽量把 <strong>footer.php</strong> 里没用的代码全部删除，当然不包括主题作者遗留的信息，尊重版权就必须以超链接形式完整保留作者的网站。</p><p><span style="color: #0080ff;"><strong>3、HTML 代码的精简</strong></span></p><p>在 <strong><a title="Hyper Cache" href="http://wordpress.org/extend/plugins/hyper-cache/">Hyper Cache</a></strong> 插件里有一个 <strong>Optimize HTML</strong> 功能，能清空源代码中不需要的空格，谨慎使用，假如你和本站一样使用<strong>&lt;pre&gt;&lt;/pre&gt;</strong>代码标签，那么就别用了。</p><p>另外，多学习一些 <strong>HTML</strong> 知识，推荐一个介绍 <strong>HTML</strong> 代码压缩的工具网站：<a title="网页压缩" href="http://www.softsea.net/cat/21003.htm"><strong>网页压缩</strong></a></p><p><span style="color: #0080ff;"><strong>4、淫荡的时间到咯</strong></span></p><p>说了那么多，只要多去尝试，相信你一定能做出一个大概两三秒就能加载完毕的首页，那么，就让淫荡的语言再来总结一下吧：我知道某某同志们喜欢看这段。</p><p>说起敲网页编程代码，<strong>HTML PHP ASP </strong>之类的，真TM就像是在 <strong>ML</strong> 。 <strong>ML</strong> 希望什么？持久？高潮迭起？每当一段代码不合适，然后千方百计去换个更好的，浪费时间不说，脸还鳖得通红，像不像高潮快到的时候？那么……就差射精咯？但是，搞出来的代码偏偏和射精有差异，你以为真的射出来的是浆糊呀？搞出来的代码希望时间越短，代码越少……而射出来的精子却希望时间越长，精子越多，我有好几亿呢！</p><p><span style="color: #0080ff;"><strong>下次有空继续，本文能无条件转载，记住，淫荡的人生，是不需要解释的……</strong></span></p><p><span style="color: #0080ff;"> </span></p><h2  class="related_post_title">相关文章</h2><ul class="related_post"><li><a href="http://zou.lu/optimize-wordpress-themes-html-codes/" title="优化你的 WordPress 之精简全站 HTML 代码（终极篇）">优化你的 WordPress 之精简全站 HTML 代码（终极篇）</a> (90)</li><li><a href="http://zou.lu/optimize-wordpress-themes-css-and-js-codes/" title="优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）">优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）</a> (79)</li><li><a href="http://zou.lu/optimize-wordpress-database-query-middle-object-cache/" title="优化你的 WordPress 之减少数据库查询次数（中级篇补充之 Object Cache）">优化你的 WordPress 之减少数据库查询次数（中级篇补充之 Object Cache）</a> (43)</li><li><a href="http://zou.lu/optimize-wordpress-database-query-middle/" title="优化你的 WordPress 之减少数据库查询次数（中级篇）">优化你的 WordPress 之减少数据库查询次数（中级篇）</a> (30)</li><li><a href="http://zou.lu/optimize-wordpress-database-query-rookie/" title="优化你的 WordPress 之减少数据库查询次数（初级篇）">优化你的 WordPress 之减少数据库查询次数（初级篇）</a> (28)</li><li><a href="http://zou.lu/use-cook-free-domain-for-your-wordpress/" title="提高 WordPress 速度之独立域名图床">提高 WordPress 速度之独立域名图床</a> (160)</li><li><a href="http://zou.lu/wpjam/" title="WordPress Jam &#8211; WP 建站服务一条龙">WordPress Jam &#8211; WP 建站服务一条龙</a> (63)</li><li><a href="http://zou.lu/mobilepress-themes-fixed/" title="MobilePress 主题汉化并修改">MobilePress 主题汉化并修改</a> (73)</li><li><a href="http://zou.lu/private-themes/" title="换上私人主题 + 清理友链">换上私人主题 + 清理友链</a> (187)</li><li><a href="http://zou.lu/chinese-beauties-in-wordpress-ii/" title="WordPress 中文界的美女们（第二期，有照片）">WordPress 中文界的美女们（第二期，有照片）</a> (309)</li></ul><hr /><div style="padding: 5px 10px; background: rgb(243, 245, 252) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"><p>© from <a href="//zou.lu/?from=feed">走点路博客</a>, 2009/05/11. | <a href="http://zou.lu/optimize-wordpress-themes-codes-normal/">优化你的 WordPress 之精简 HTML 代码（进阶篇）</a> | <a href="http://zou.lu/optimize-wordpress-themes-codes-normal/#comments">32 只留言鸟</a> <br /> Tags： <a href="http://zou.lu/tags/wordpress/" rel="tag">WordPress</a>, <a href="http://zou.lu/tags/wordpress%e4%bc%98%e5%8c%96/" rel="tag">WordPress优化</a> | <a href="//zou.lu/?p=36">Link</a> | <a href="http://zi.mu/domain"><font color="red">.me 域名全国最低价，首年仅需40元，续费130元促销中！</font></a></p></div>]]></content:encoded> <wfw:commentRss>http://zou.lu/optimize-wordpress-themes-codes-normal/feed/</wfw:commentRss> <slash:comments>32</slash:comments> </item> <item><title>优化你的 WordPress 之减少数据库查询次数（初级篇）</title><link>http://zou.lu/optimize-wordpress-database-query-rookie/</link> <comments>http://zou.lu/optimize-wordpress-database-query-rookie/#comments</comments> <pubDate>Sun, 10 May 2009 13:58:57 +0000</pubDate> <dc:creator>Showfom</dc:creator> <category><![CDATA[WordPress]]></category> <category><![CDATA[WordPress优化]]></category><guid isPermaLink="false">http://zou.lu/?p=34</guid> <description><![CDATA[闲逛了一下 ThinkAgain 的博客，发现他小子的查询次数： &#60;!-- 6 queries. 1.683 seconds. --&#62; 真是的，才六次查询，时间慢了点…… 然后疯狂优化我自己的 WordPress ，参考了 ゞ猫 的方法，使用了 WP Widget Cache ，个人觉得现在流量小，不必用 Object Cache 缓存。 接着，使用了两个 widget ，一个是最新文章，一个是最新留言。 接下来，把多余的都直接 HTML 打在 sidebar.php 上，哦了，世界从此清净，查询次数，你以为射精啊，当然越少越好，时间越少越好，就让他妈的 WordPress 的查询次数见鬼去吧！ 然后这几天的打算是把整个博客的查询次数减少到10左右，要熄灯了，明天继续！ PS：写代码修改代码真的如同做爱，时间越久就越兴奋，最后达到高潮，射精之后疲惫，然后……XXOO 各位明天继续 相关文章优化你的 WordPress 之精简全站 HTML 代码（终极篇） (90)优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充） (79)优化你的 WordPress 之减少数据库查询次数（中级篇补充之 Object Cache） (43)优化你的 WordPress 之减少数据库查询次数（中级篇） (30)优化你的 WordPress [...]]]></description> <content:encoded><![CDATA[<p>闲逛了一下 <a href="http://www.thinkagain.cn/">ThinkAgain</a> 的博客，发现他小子的查询次数：<br /> <span id="more-34"></span></p><blockquote><p>&lt;!-- 6 queries. 1.683 seconds. --&gt;</p></blockquote><p>真是的，才六次查询，时间慢了点……</p><p>然后疯狂优化我自己的 WordPress ，参考了 <a href="http://www.maoxmao.com/">ゞ猫</a> 的方法</span>，使用了 <a href="http://wordpress.org/extend/plugins/wp-widget-cache/">WP Widget Cache</a> ，个人觉得现在流量小，不必用 <strong>Object Cache</strong> 缓存。</p><p>接着，使用了两个 <strong>widget</strong> ，一个是最新文章，一个是最新留言。</p><p>接下来，把多余的都直接 <strong>HTML</strong> 打在 <strong>sidebar.php</strong> 上，哦了，世界从此清净，查询次数，你以为射精啊，当然越少越好，时间越少越好，就让他妈的 <strong>WordPress</strong> 的查询次数见鬼去吧！</p><p>然后这几天的打算是把整个博客的查询次数减少到10左右，要熄灯了，明天继续！</p><p>PS：写代码修改代码真的如同做爱，时间越久就越兴奋，最后达到高潮，射精之后疲惫，然后……XXOO 各位明天继续</p><h2  class="related_post_title">相关文章</h2><ul class="related_post"><li><a href="http://zou.lu/optimize-wordpress-themes-html-codes/" title="优化你的 WordPress 之精简全站 HTML 代码（终极篇）">优化你的 WordPress 之精简全站 HTML 代码（终极篇）</a> (90)</li><li><a href="http://zou.lu/optimize-wordpress-themes-css-and-js-codes/" title="优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）">优化你的 WordPress 之压缩 CSS/JS 代码（进阶篇补充）</a> (79)</li><li><a href="http://zou.lu/optimize-wordpress-database-query-middle-object-cache/" title="优化你的 WordPress 之减少数据库查询次数（中级篇补充之 Object Cache）">优化你的 WordPress 之减少数据库查询次数（中级篇补充之 Object Cache）</a> (43)</li><li><a href="http://zou.lu/optimize-wordpress-database-query-middle/" title="优化你的 WordPress 之减少数据库查询次数（中级篇）">优化你的 WordPress 之减少数据库查询次数（中级篇）</a> (30)</li><li><a href="http://zou.lu/optimize-wordpress-themes-codes-normal/" title="优化你的 WordPress 之精简 HTML 代码（进阶篇）">优化你的 WordPress 之精简 HTML 代码（进阶篇）</a> (32)</li><li><a href="http://zou.lu/use-cook-free-domain-for-your-wordpress/" title="提高 WordPress 速度之独立域名图床">提高 WordPress 速度之独立域名图床</a> (160)</li><li><a href="http://zou.lu/wpjam/" title="WordPress Jam &#8211; WP 建站服务一条龙">WordPress Jam &#8211; WP 建站服务一条龙</a> (63)</li><li><a href="http://zou.lu/mobilepress-themes-fixed/" title="MobilePress 主题汉化并修改">MobilePress 主题汉化并修改</a> (73)</li><li><a href="http://zou.lu/private-themes/" title="换上私人主题 + 清理友链">换上私人主题 + 清理友链</a> (187)</li><li><a href="http://zou.lu/chinese-beauties-in-wordpress-ii/" title="WordPress 中文界的美女们（第二期，有照片）">WordPress 中文界的美女们（第二期，有照片）</a> (309)</li></ul><hr /><div style="padding: 5px 10px; background: rgb(243, 245, 252) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"><p>© from <a href="//zou.lu/?from=feed">走点路博客</a>, 2009/05/10. | <a href="http://zou.lu/optimize-wordpress-database-query-rookie/">优化你的 WordPress 之减少数据库查询次数（初级篇）</a> | <a href="http://zou.lu/optimize-wordpress-database-query-rookie/#comments">28 只留言鸟</a> <br /> Tags： <a href="http://zou.lu/tags/wordpress/" rel="tag">WordPress</a>, <a href="http://zou.lu/tags/wordpress%e4%bc%98%e5%8c%96/" rel="tag">WordPress优化</a> | <a href="//zou.lu/?p=34">Link</a> | <a href="http://zi.mu/domain"><font color="red">.me 域名全国最低价，首年仅需40元，续费130元促销中！</font></a></p></div>]]></content:encoded> <wfw:commentRss>http://zou.lu/optimize-wordpress-database-query-rookie/feed/</wfw:commentRss> <slash:comments>28</slash:comments> </item> </channel> </rss>