<?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; Bug</title>
	<atom:link href="http://xirang.us/tag/bug/feed" rel="self" type="application/rss+xml" />
	<link>http://xirang.us</link>
	<description>if you see something, say something.</description>
	<lastBuildDate>Fri, 11 Jun 2010 14:23:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>WP Super Cache之诡异GZip压缩包下载BUG</title>
		<link>http://xirang.us/2009/12/peculiar-gzip-download-bug-of-wp-super-cache</link>
		<comments>http://xirang.us/2009/12/peculiar-gzip-download-bug-of-wp-super-cache#comments</comments>
		<pubDate>Mon, 21 Dec 2009 09:00:55 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[信息时代]]></category>
		<category><![CDATA[编程开发]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[插件]]></category>
		<category><![CDATA[网站建设]]></category>

		<guid isPermaLink="false">http://xirang.us/?p=1422</guid>
		<description><![CDATA[WP Super Cache 0.9.8导致浏览器无法打开基于Wordpress架设的网站，而是提示访问者下载GZip压缩包，该压缩包解压后，为网站首页的html文档。并且任何内核的浏览器都可能出现此情况。]]></description>
			<content:encoded><![CDATA[<p>本文发表在<a href="http://xirang.us" target="_blank">嘻来嚷往国际版</a>，作者<a href="http://xirang.us/author/tim" target="_blank">Tim</a>。您可以<a href="http://xirang.us/2009/12/peculiar-gzip-download-bug-of-wp-super-cache#comments" target="_blank">参与本文评论</a>或是follow本站的<a href="https://twitter.com/xirang" target="_blank" title="嘻来嚷往官方Twitter">Twitter帐号</a>。<br />
<hr size="1" color="#bd1016"/></p>
<p>请各个基于Wordpress架设并且开启了WP Super Cache插件进行提速的网站的站长们注意，在嘻来嚷往热心读者的帮助下，我们发现了WP Super Cache 0.9.8版本所引入的一个十分诡异和难以察觉的BUG！</p>
<p style="text-align: center; "><a href="http://xirang.us/media/2009/12/bug-fest.jpg"><img alt="bug-fest" class="alignnone size-full wp-image-1424" height="548" src="http://xirang.us/media/2009/12/bug-fest.jpg" title="bug-fest" width="600" /></a></p>
<h2>前提条件</h2>
<ol>
<li>WP Super Cache Status: 开启</li>
<li>Super Cache Compression: 开启</li>
<li>Expiry Time &amp; Garbage Collection: 较长，比如嘻来嚷往设定为86400秒（一天）</li>
</ol>
<p>如果您Wordpress网站的WP Super Cache设置符合上述三个条件，请向贵站的读者咨询他们在访问网站时是否出现过以下（比较罕见，就算您自己刷新网站100次可能也不会出现，所以做好求助于网站的大量访问者）</p>
<h2>现象</h2>
<p>浏览器无法打开网站，而是提示访问者<strong>下载GZip压缩包</strong>，该压缩包解压后，为网站首页的html文档。并且任何内核的浏览器都可能出现此情况。<span id="more-1422"></span></p>
<p>如果收到了上诉现象的报告，那么恭喜您的网站中招了！尽管进入WP Super Cache设置页面，<strong>清除缓存</strong>后GZip压缩包下载现象立即消失，但是<strong>不久后又会出现<span class="Apple-style-span" style="font-weight: normal; ">；并且一旦出现过一次这样的情况，就算关闭WP Super Cache的Super Cache Compression选项试图亡羊补牢却仍然无济于事。</span></strong></p>
<p>半个月前，本站访问者开始报告这个现象，当时凭直觉断定肯定是WP Super Cache的问题，但问题在哪里并不清楚，只好彻底卸载WP Super Cache后全新安装，并关闭Super Cache Compression选项，这样似乎持续了一个星期问题未再出现。</p>
<p>可是后来再次出现很多遇到了GZip压缩包下载的现象报告，崩溃之余开始搜索，无果！只好去WP Super Cache的支持论坛一页页翻看，终于发现一位外国老兄也也遇到了<a href="http://wordpress.org/support/topic/334359" target="_blank">这个情况</a>。但是插件作者坚称这不是WP Super Cache的BUG，其原话如下：</p>
<blockquote>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Lucida Grande', 'Lucida Sans Unicode', Arial, Verdana, sans-serif; font-size: 14px; line-height: 22px; ">Very very occasionally, the front page becomes a gzip file that downloads. It happened here once and I examined the cache file. There was nothing wrong with it. It was perfect. I suspect Apache and mod_rewrite got confused somehow but clearing the cache fixed it. The file generated after was exactly the same size as the old one, so no chance it got &ldquo;double gzipped&rdquo;.</span></p>
</blockquote>
<h2>解决方案</h2>
<p>我就纳闷了，服务器配置未更改过、Wordpress主程序也未升级过，外部环境都没改变，可是WP Super Cache升级到0.9.8就出现这个问题，难道不是它的BUG？这BUG真够诡异，连作者自己都无法找到问题的根源，只能坚称这是Apache的问题，不过他还是给出了一个<strong>指标不治本</strong>的解决方案。</p>
<p>打开/wp-contents/wp-cache-config.php文件，在其中加入下面这行代码：</p>
<p>[cc lang=&quot;PHP&quot;]$wp_super_cache_advanced_debug = 1;[/cc]</p>
<p>接着进入WP Super Cache设置页面，将看到以下<strong>Advanced</strong>部分</p>
<p style="text-align: center; "><a href="http://xirang.us/media/2009/12/wpsc-advanced.jpg"><img alt="wpsc-advanced" class="alignnone size-full wp-image-1423" height="305" src="http://xirang.us/media/2009/12/wpsc-advanced.jpg" title="wpsc-advanced" width="606" /></a></p>
<p>开启之后，WP Super Cache将每隔五分钟检查一次网站首页，并在首页数据中搜索指定的字符串，如果字符串不存在，WP Super Cache就认为网站首页缓存出错，于是会自动清除并重建缓存。</p>
<p>WP Super Cache作者还说，如果这样也不能解决问题，那就只有把Expiry Time &amp; Garbage Collection设为5分钟或者更短，以让WP Super Cache频繁清除缓存。我想如果非这样不可，还不如卸载了WP Super Cache，如此频繁的重建缓存，只会降低Wordpress的速度&hellip;&hellip;期待WP Super Cache作者找到问题根源在下个版本中除掉这个BUG！</p>
<div style="clear:both">
<h3>著作权信息（站外使用本文请保留以下内容）</h3>
<hr size="2" />
<table width="100%">
<tbody>
<tr>
<td>文章作者：<a  href="http://xirang.us/author/tim">Tim</a><br />原始站点：<a title="嘻来嚷往" href="http://xirang.us/" target="_self">嘻来嚷往 &#8211; IF YOU SEE SOMETHING, SAY SOMETHING.</a><br />原文标题：WP Super Cache之诡异GZip压缩包下载BUG<br />发表日期：2009年12月21日<br />原文链接：<a href="http://xirang.us/2009/12/peculiar-gzip-download-bug-of-wp-super-cache" >http://xirang.us/2009/12/peculiar-gzip-download-bug-of-wp-super-cache</a></td>
<td class="author_img"><center><img alt='' src='http://0.gravatar.com/avatar/6f9a9d5526438d3a59313a2603020217?s=100&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D100&amp;r=R' class='avatar avatar-100 photo' height='100' width='100' /></center></td>
</tr>
<tr>
<td>版权协议：本作品采用<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.5/cn/" target="_blank">知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议</a>进行许可，作品中的文字和图像若非明确指出著作权归属则均受到该协议<a title="知识共享协议法律文本" href="http://creativecommons.org/licenses/by-nc-nd/2.5/cn/legalcode" target="_blank">法律文本</a>的保护。站外使用请严格遵守协议，<a href="http://xirang.us/" target="_self">嘻来嚷往</a>站保留诉诸法律的权利！如有异议请与站长<a title="联系我们" href="http://xirang.us/affairs" target="_self">联系</a>。</td>
<td><center><img src="http://i.creativecommons.org/l/by-nc-nd/2.5/cn/88x31.png" alt="BY-NC-ND" /></center></td>
</tr>
</tbody>
</table>
<hr size="2" /></div>
<p style="text-align:center"><a href="http://clustrmaps.com/counter/maps.php?url=http://xirang.us" id="clustrMapsLink" title="嘻来嚷往双站总独立IP访问量" target="_blank"><img src="http://clustrmaps.com/counter/index2.php?url=http://xirang.us" alt="" id="clustrMapsImg" /></a><img src="http://nojsstats.appspot.com/UA-9442677-1/xirang.us" alt="" /></p>
<img src="http://xirang.us/?ak_action=api_record_view&id=1422&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://xirang.us/2009/12/peculiar-gzip-download-bug-of-wp-super-cache/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
