> 嘎嘎,小邪是标准的缓存控,啥都想要缓存一下以加快速度,所以这次要把 Super-Cache 搞定。
> 如果用的 Apache,是不需要那么麻烦的。不过如果用的是 Nginx,那么,来,开始强力折腾。

一. 使WP-Super-Cache支持Nginx:
> 首先登陆 SSH,进入 Nginx 的配置文件,然后创建一个新文件,保存为 WordPress_001.conf。
1 2 | -bash-3.2# cd /usr/local/nginx/conf -bash-3.2# vi wordpress_001.conf |
> 然后将下面内容贴入编辑器。以下代码由插件作者博客处获取,有兴趣请过此传送门传送查看。
> 传送门 - http://ocaoimh.ie/wordpress-nginx-wp-super-cache/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | location / { # if the requested file exists, return it immediately if (-f $request_filename) { break; } set $supercache_file ''; set $supercache_uri $request_uri; if ($request_method = POST) { set $supercache_uri ''; } # Using pretty permalinks, so bypass the cache for any query string if ($query_string) { set $supercache_uri ''; } if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) { set $supercache_uri ''; } # if we haven't bypassed the cache, specify our supercache file if ($supercache_uri ~ ^(.+)$) { set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html; } # only rewrite to the supercache file if it actually exists if (-f $document_root$supercache_file) { rewrite ^(.*)$ $supercache_file break; } # all other requests go to WordPress if (!-e $request_filename) { rewrite . /index.php last; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | :wq //接着保存退出编辑器 P.s. 双斜杠及后续内容表示注释 -bash-3.2# cd ../ //这个命令是返回上层目录 -bash-3.2# ls //列出目录文件 dabr.conf koi-utf other.conf discuz.conf koi-win sablog.conf fastcgi.conf mime.types typecho.conf fastcgi.conf.default mime.types.default vhost fastcgi_params n.conf win-utf fastcgi_params.default nginx.conf wordpress.conf fcgi.conf nginx.conf.default wordpress_evlos.conf imsurl.conf none.conf -bash-3.2# vi nginx.conf //如果直接建立在主机上,就编辑这个配置文件 -bash-3.2# cd vhost //否则就请进入虚拟主机配置文件目录 -bash-3.2# vi evlos.org.conf //编辑当前虚拟主机配置文件 |
1 2 3 4 | root /home/host/evlos.org; //一般找到上面这行配置 include wordpress_001.conf; //然后添加下面这行来载入刚才的 Wordpress_001.conf,如果已经存在则修改 |
1 2 | -bash-3.2# ./lnmp restart //如果是 Lnmp,那么重启一下就OK鸟,嘿嘿嘿 |
二. 关于插件的配置:
> 首先启用 WP-Super-Cache 插件,如果要设置手机访问缓存,请选择 Mobile device support。

> 缓存时间设置为 864000 秒,因为发表文章和评论时会自动更新,所以小邪觉得这样蛮合理的。

三. Preload Cache:
> 因为这个插件的汉化包不是最新的,所以请大家挺住,这里英文小邪会简单讲解一下,要蛋定。

> 下面小邪会简单翻译一下,并按照自己的理解补充进行一下说明,呵呵,不好的地方请见谅哈。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | This will cache every published post and page on your site. It will create supercache static files so unknown visitors (including bots) will hit a cached page. This will probably help your Google ranking as they are using speed as a metric when judging websites now. //简单说,一般缓存文件都是在用户访问这个页面时候才产生的,也就是说如果清理过缓存,那么所有的页面只有在被访问的时候才会产生缓存。如果是 Google 对网站进行排名的时候,(因为目前 Google 也将网站的访问速度作为一个重要的评价因素 By 小邪),所以会对这个评价有不利的影响,(汗,应该也就是小邪的评价一直很低的原因)。 Preloading creates lots of files however. Caching is done from the newest post to the oldest so please consider only caching the newest if you have lots (10,000+) of posts. This is especially important on shared hosting. //预加载的作用是提前将博客里面所有的页面都提前一次性批量生成缓存,但是请注意在生成的时候会占用一定的资源,如果是合租VPS之类的,(请在访问量小的时候进行 by 小邪)。 In ’Preload Mode’ regular garbage collection will only clean out old half-on files for known users, not the preloaded supercache files. This is a recommended setting when the cache is preloaded. //缓存文件操作与 WP-super-cache 半开启状态的文件无关 Refresh preloaded cache files every minutes. (0 to disable, minimum 30 minutes.) //缓存文件刷新时间,小邪觉得这里填半个月都木有关系,21600 min 为半个月 Preload mode (garbage collection only on half-on cache files. Recommended.) //开启预加载模式 Send me status emails when files are refreshed. //预加载邮件报告功能开关 Many emails, 2 emails per 100 posts. Medium, 1 email per 100 posts. Less emails, 1 at the start and 1 at the end of preloading all posts. |
三. 关于菠萝阁回复邮件通知被认为垃圾邮件:
> 额,杯具了这个,小邪的回复邮件通知不知道被谁举报为垃圾邮件,所以 Gmail 进行了过滤。
> 目前的解决办法 -
> 1. 请点击 Gmail 邮件窗口顶部的 “创建过滤器”
> 2. 发件人处请填入 lost578@gmail.com 并点击下一步
> 3. 将 “不要将其发送至“垃圾邮件”” 勾选并点击更新过滤器即可
> 好大的一个茶几啊啊 ~ ~ (~o ̄▽ ̄)~o ~,回头看看发封邮件给谷歌有木有用,春哥保佑 >.<。
深夜占sf
@winy , 哇,极速啊这个 ~
荒淫荒淫 ~ 嘎嘎嘎 ~
Nginx没用过,不懂
我能收到邮件通知啊,gmail的
@winy , 哇,能收到吗?呵呵,真开心
我想知道 Nginx下子目录的 伪静态规则该怎么写 我现在是根目录一个Wordpress伪静态了 子目录还有一个 不会写规则了。。
@阿邙 , 嘿嘿,其实解决办法就在这个东西上 “location / {” ~
如果你的子目录是 /blog/ ~
那么就应该用 “location /blog/ {” ~
就木有问题鸟 ~~
@邪 罗刹,
关键是我根目录也有
@阿邙 , 呵呵 因为一个 location 的内容结束的时候需要 “}” 框住 ~
所以只要先 location / {根目录的规则} 后面在接上 location /blog/ {子目录的规则} ~
就ok了 ~
@邪 罗刹,
括号内的不动么?
@阿邙 , 恩,括号内保持正常就好 ~
比如我有俩个 WordPress,一个在根目录 一个在子目录 /sky/ 中 ~
那么就按照下面这样写规则 ~
@邪 罗刹,
好的 俺试试去 先谢谢小邪啦~
@阿邙 , 呵呵,不客气 ~
先睡了 撑不住了呢 刚才洗漱完发现手机提示邮件才上来看看的 ~
你也别熬夜了 不好的 有问题请留言呐 ~
@邪 罗刹,
恩恩 俺弄完这个就睡哈~
@邪 罗刹,
评论里可以贴代码?插件吗?
@万戈 , 嘎嘎,是 WP-Syntax 插件,用和在文章里面一样贴代码的方法来贴就OK鸟 ~
很细致的技术
真够复杂的。没用这插件~
@柳城 , 嘿嘿,做SEO保险点还是不要了 ~
用这个能提速不少^_^
@久酷 , 恩恩,缓存的爽的感觉,嘎嘎嘎 ~
用这个唯一的杯具就是...统计数失效
@mice , 汗,这个是一个问题 ~
@邪 罗刹,
我又重新启用这个插件了,要不然要被小张赶出服务器了...
原来一直用的object-cache.php,貌似效果不好..
为了能在小张服务器里呆,只能忍通割爱把主题所有统计全部下掉,全部重做了...
@mice , 呵呵,再推荐一个可以和 SuperCache 一起用的插件,Widget cache ~
可以缓存侧边栏,蛮不错的 ~
统计如果代码的思路不好,肯定灰常占用资源的,所以小邪这里都木有统计的呢 ~
@邪 罗刹,
万戈那什么缓存都没用呢- .-想不通 我网站里面什么能消耗cpu了..主题能优化的地方都优化了...
@mice , ........................ 万戈是火星人,无视他
万戈的 -- 本页载入信息: 21 次查询. 耗时0.680 秒.
你的 -- 本页载入信息:65次查询.耗时0.313秒.
说真的,你的优化是做得不错,但是估计还是主题的问题,查询次数太高了 ~
建议你可以用 DB Cache Reloaded 来直接缓存查询 ~
当然,不知道新版的和 SuperCache 的兼容性如何 ~
所以建议用卸载的方式关闭 SuperCache 来测试 ~
http://wordpress.org/extend/plugins/db-cache-reloaded/
得想点办法减少数据库的查询量提速啊~
@疾风 , 数据库好脆弱的说 ~
都是一些技术性的文章哦,有时间得深究深究:lol:
@WordPress啦 , 呵呵 希望对你有帮助呐 ~
这个插件以前用过,觉得我那点访问量不需要,只用了db-cache
@zwwooooo , 嘿嘿,小邪对速度太敏感鸟,受不鸟太慢的呢 ~ ╮(╯▽╰)╭
绿色的注释斜体中文很难看清楚的说,可以改一下geshi里面相应文件的css...
@fatkun , 呵呵,因为是个人爱好 ~
不过不要担心,小邪会修改一下,嘿嘿 ~
看不懂!呵呵!
@于泽鹏 , 没事儿,荒淫来玩 ~
没有一篇文章能看懂。。囧。。
@沉冰浮水 , 蛋定蛋定蛋定蛋定,一定要蛋定,
@沉冰浮水 , 。。。。。。老兄 想在你博客留言 但是死活找不到填用户名和网址邮件的输入框
@沉冰浮水 , 喔喔,不是说你,呵呵不好意思,搞错鸟 ·
不明真相。。
@沉冰浮水 , 蛋定 ~ 蛋定 ~
嘿嘿 小托来支持小邪了 为什么我看不懂 为什么呢 。呜呜
@网站推广方法 , 蛋定,一定要蛋定,习惯就好鸟 ╮(╯▽╰)╭ ~~
咋不整点异国风情啊~
@北街 , .... 您老还是弄个黄网上上算了
你博客的流量似乎还用不到这玩意吧,
@风吟 , 呵呵,我的VPS上又不止这一个应用 ..
好像在万戈那里听过。
@猪八戒的博客 , 恩?万戈?他也用 Nginx 么?囧,呵呵,别重复了 ~
@邪 罗刹 ,