标题喜感一些~ 呵呵,其实就是WP SUPER CACHE 这个插件 众所周知WP自身没有缓存机制,这是让人多么蛋疼的一件事情啊~,程序本身做大以后就已经臃肿得让人受不了了,而且这丫居然没缓存,我这个前端CSS<8K,JQ调用SAE的小博客的速度都让人要抓狂了,何况那些装了若干插件的呢. 所以今天没办法啦,必须要好博客好好整一整了. 比较影响速度的因素有: 1. 后台(PHP+MySQL): 根据请求,运行语句,操作数据库,生成页面返回
效率低的或查询量大会让cpu飙升2. 线路: Ping 命令大家都会用,这时间就代表一个来回
(Ping偶尔会Timeout超时,也就是所谓的丢包,常规原因有2种:真丢,假丢 ; 例如有些服务器设置侦测到集中密集的ICMP包会选择性的丢弃掉 ;10次里丢1次完全不同于10次访问有一次打不开,网页是走 TCP/IP 需要3次握手 .Ping 相对重要的参数就是时间了,国外一般200-300ms左右,国内一般100内)3. 前台: 闻名的 yslow 34 rules, 做了这些简单的调整, 可以明显的提速25%-50% 后台的优化非一朝一夕能够完成,这个要慢慢来. 线路问题也没什么办法了,我的VPS主机在美国,速度也还成,虽然达不到飞快. 所以只能从前台想办法了,最简单有效的方法无非是静态化了.所以先从这里找办法,google了一番发现了
超级擦车(super cache)的大名.于是乎兴高采烈的下下来,才傻眼了. 原来这货非要url_rewrite才成.于是乎要标记一个好网页,他可以把.htaccess转换成nginx格式,地址在这里http://www.anilcetin.com/convert-apache-htaccess-to-nginx/ 做完这一步以后在后台设置一番,修改完url_rewrite以后才惊喜的发现 超级擦车 还支持预缓存,真是欣喜万分啊. 全部设置完成以后,缓存打开,发现速度果然快了很多,基本上是秒开了. 这里省略的步骤如下
vim wordpress_params_regular
# WordPress pretty URLs if (-f $request_filename) { expires max; break; } if (-d $request_filename) { break; } rewrite ^(.+)$ /index.php?q=$1 last; # Enable nice permalinks for WordPress error_page 404 = //index.php?q=$uri;
此为配置nginx下的rewrite,这里说一下,Lnmp的集成包里面已经包含了大部分国内常见程序的rewrite配置,非常方便,推荐各位VPSER使用~
vim wordpress_params_supercache
创建超级擦车的配置文件
# if the requested file exists, return viagra price it immediately if (-f $request_filename) { expires 30d; 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 /var/www/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 . /var/www/index.php last; }
两个配置文件写完,再到nginx的conf里 把两个文件include进去,然后重启nginx,大功告成
Recent Comments