WordPress使用Nginx配置wp-supercache缓存插件

wp-supercache是个很出色的缓存插件,可以wordpress完全静态化.这样用户访问的就是一些静态的html.而不用后端apache等动态解析php.
只是该插件支持apacherewrite.对于nginx的话就得自己手动配置了.下面贴出我的配置文件.直接includewordpress站的虚拟主机配置文件就好了

gzip_static on;

set $supercacheuri "";
set $supercachefile "$document_root/wp-content/cache/supercache/${http_host}${uri}index.html";
if (-e $supercachefile) {
    set $supercacheuri "/wp-content/cache/supercache/${http_host}${uri}index.html";
}

# 不为post缓存
if ($request_method = POST) {
    set $supercacheuri "";
}

# 不为querystring缓存
if ($query_string) {
    set $supercacheuri "";
}

# 不为已登录用户缓存
if ($http_cookie ~* comment_author_|wordpress_logged_in|wp-postpass_) {
    set $supercacheuri "";
}


# 手机支持
if ($http_x_wap_profile) {
    set $supercacheuri "";
}

if ($http_profile) {
    set $supercacheuri "";
}

if ($http_user_agent ~* (2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800)) {
    set $supercacheuri "";
}

if ($http_user_agent ~* (w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-)) {
    set $supercacheuri "";
}


if ($supercacheuri) {
    rewrite ^ $supercacheuri break;
}  

好了.就这些啦.再也不怕被爆站了.哈哈哈

发表评论

电子邮件地址不会被公开。 必填项已用*标注