
Nginx使用Memcached缓存加速wordpress,秒开网站
Nginx使用Memcached缓存,秒速响应网站
这里以常用的wordpress博客程序为例
下面是Nginx使用Memcached缓存wordpress的代码
//跳过一些缓存,比如写作文章和后台地址
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
location / {
error_page 404 405 = @nocache;
if ( $query_string ) {
return 405;
}
if ( $request_method = POST ) {
return 405;
}
if ( $request_uri ~ "/wp-" ) {
return 405;
}
if ( $http_cookie ~ (wp-postpass|wordpress_logged_in|comment_author)_ ) {
return 405;
}
default_type text/html;
add_header X-Powered-By Cachetest;
set $memcached_key $host$uri;
memcached_pass localhost:11211;
}
//NOCACHE LOCATION##下面的代码是wordpress伪静态代码,其它地方请勿添加
location @nocache {
try_files $uri $uri/ /index.php?$args;
}