WordPress Nginx 环境 wp Super Cache 插件专家模式重写规则

周俊奇
周俊奇
周俊奇
267
文章
0
评论
2019年12月16日15:58:36
评论
3

wp_super_cache 插件Mod_Rewrite缓存(专家模式)、PHP缓存(传统模式);其中以Mod_Rewrite缓存最快,但是Mod_Rewrite缓存默认是仅支持 apache web 服务的,如果我们的服务器是 nginx,这就有点麻烦了;需要单独修改重修规则,我的整个重写规则文件代码如下

# WP Super Cache rules.
# Designed to be included from a 'wordpress-ms-...' configuration file.
 
set $cache_uri $request_uri;
 
# 请求方式为post时不使用缓存
if ($request_method = POST) {
        set $cache_uri 'null cache';
}
 
if ($query_string != "") {
        set $cache_uri 'null cache';
}   
 
# uri包含以下内容时不使用缓存
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';
}   
 
# 对登录用户或已发布评论用户不使用缓存
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
        set $cache_uri 'null cache';
}
 
# START MOBILE
# 如果需要在移动端禁用缓存,可以把代码前的#删掉
# if ($http_x_wap_profile) {
#        set $cache_uri 'null cache';
#}
 
#if ($http_profile) {
#        set $cache_uri 'null cache';
#}
 
#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 $cache_uri 'null cache';
#}
 
#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 $cache_uri 'null cache';
#}
#END MOBILE
 
# 如果存在缓存,则使用缓存,如果没有缓存,直接转向动态页面
location /
{
	 try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?$args ;
}

 

WordPress Nginx 环境 wp Super Cache 插件专家模式重写规则

 

备注:如果网站流量不是很大(同时在线访问人数 100 以下,日访问量低于 10000 页面)建议使用传统模式,无需修改重写规则。

周俊奇
  • 本文由 发表于 2019年12月16日15:58:36
  • 转载请务必保留本文链接:https://www.bikaao.com/archives/968.html
建议给老人手机都安装下“国家反诈中心”app 防诈骗

建议给老人手机都安装下“国家反诈中心”app

“国家反诈中心”app正式上线半年来,安卓、苹果手机均可在应用商店搜索下载。这是国家层面为了防诈推出的官方APP,可有效防范诈骗,守护群众的“钱袋子”,尤其老年人,由于接受信息能力比较弱,建议有智能机...
如何预防无卡预约诈骗 防诈骗

如何预防无卡预约诈骗

首先去网上找案例吧,下面是复制网上的。 部分银行推出的“无卡预约”便捷取款服务,给一些犯罪嫌疑人带来了“可乘之机”。近期,北京市公安局网安总队破获了“无卡预约”取款系列诈骗案件,控制犯罪嫌疑人10名,...
文档字体和大小规范 产品

文档字体和大小规范

1.页面设置:页边距上2.8cm,下2.5cm,左3.0cm(装订线0.5cm),右2.5cm,,页脚1.5cm。 2.封面格式设置:字体:四号宋体,居中,指导教师签名必须手写。 3.题目:中文,三号...
国内电子发票二维码应用规范标准 产品

国内电子发票二维码应用规范标准

为便捷纳税人开具增值税发票,提高发票开具效率和准确性,参照国家相关标准,采用QR码码制,制定本应用规范。 一、编码要求 (一)二维码编码格式采用信息容量大、可靠性高、保密防伪性强的QR码码制。 (二)...
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: