一直不满意于寻ta驿站的加载速度,而wordpress的解决方案又比Django简单得多,于是便开始寻觅插件——wp super cache
A very fast caching engine for WordPress that produces static html files.
一个快速的缓存引擎用于给WordPress生成产品极的静态html文件。
果断到插件搜索WP Super Cache
安装完,打开
wp-content
于是就tree一下,有了下面的结果,然而没有缓存html。
.
|____wp-cache-ba402bb3c61119a05655cd0babe02921.html
|____config
| |____master.php
| |____index.html
|____supercache
| |____xunta.phodal.net
| | |____person
| | | |____lian-zai-ji-ke-ai-qing-xu
| | | | |____index.html
| | | |____she-jian-shang-de-cheng-xu-yuan
| | | | |____index.html
| | | |____ji-ke-ai-qing-zhi-yi-ai-ta-hai-shi-ai-wo
| | | | |____index.html
| | | |____zhong-guo-de-nan-bei-wen-hua-cha-yi
| | | | |____index.html
| | | |____category
| | | | |____thinking
| | | | | |____index.html
| | | |____ji-ke-ai-qing-zhi-er-wo-men-qu-shi-yan-shi-yue-hui-ba
| | | | |____index.html
| | |____index.html
| | |____about
| | | |____index.html
|____index.html
|____blogs
|____meta
| |____wp-cache-ba402bb3c61119a05655cd0babe02921.meta
|____tmp
|____.htaccess
因为还需要进一步设置。但是已经可以用curl找到寻ta的相关信息了
curl -I -s http://xunta.phodal.net/person/ji-ke-ai-qing-zhi-er-wo-men-qu-shi-yan-shi-yue-hui-ba/
有
HTTP/1.1 200 OK
Server: mokcy/0.17.0
Date: Wed, 04 Jun 2014 02:27:06 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: PHP/5.4.0
WP-Super-Cache: Served supercache file from PHP
X-Page-Speed: 1.7.30.4-3847
Cache-Control: max-age=0, no-cache, must-revalidate
可以看到Super Cache在里面了,接着便是配置Nginx了
添加下面的配置
set $cache_uri $request_uri;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $cache_uri 'null cache';
}
if ($query_string != "") {
set $cache_uri 'null cache';
}
# Don't cache uris containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $cache_uri 'null cache';
}
# Don't use the cache for logged in users or recent
commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
set $cache_uri 'null cache';
}
# Use cached or actual file if they exists, otherwise pass request to WordPress
location / {
try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php ;
}
需要注意location /,如果其中还有其他东西的话。
location / {
try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php ;
etag on;
FileETag on;
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
围观我的Github Idea墙, 也许,你会遇到心仪的项目