wordpress的cache插件在nginx配置和测试

这次测试的结果不是很全面的,本文将会在有新的测试结果时再修改

1.使用前文一套wordpress安装N个不同的wordpress站点的方式

刚开始使用30多个插件,然后崩溃的让我减掉了只剩15个插件,配置WordPress+W3 Total Cache+eAccelerator

为什么不用磁盘高速呢?因为这样一套多站,多数据库的方式用磁盘高速的话会出现问题的,这个问题很严重!

用eAccelerator是解决了问题,但如果后台更新时内存一下就爆了。郁闷死了,有空再把这些站点分开然后再用W3 Total Cache磁盘增强模式了

2013更新W3 Total Cache的nginx的配置规则:


##w3 cache begin##
              set $cache_uri $request_uri;
	#  带有查询字符串的POST请求和URL应始终转到PHP 
	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';
	}   
	# 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';
	}
	# 如果他们退出,使用缓存或当前文件,其他方式请求工作
	location / {
		try_files /wp-content/cache/page_enhanced/${host}${cache_uri}_index.html $uri $uri/ /index.php?$args ;
	}
             location ~ ^/wp-content/cache/minify/[^/]+/(.*)$ {
                try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1;
	}

location ~ ^/(html|images|javascript|js|css|flash|media|static|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|webp|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|webm|mpp|otf|_otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|_ttf|wav|wma|wri|woff|woff2|xla|xls|xlsx|xlt|xlw|zip)$ {
root   /home/bae/app;
    expires 3d;
}

 
Comet Cache的nginx配置

server {

  # ↓ See: http://nginx.org/en/docs/http/ngx_http_core_module.html#etag
  # This reduces load on your server by supporting the If-Modified-Since header,
  # since by browsers for static resources.

  etag on;
  expires 7d;
  if_modified_since before;

  # ↓ See: http://nginx.org/en/docs/http/ngx_http_gzip_module.html#gzip
  # This enables GZIP compression in Nginx, making all static
  # resources load faster in browsers.

  gzip on;
  gzip_vary on;
  gzip_comp_level 6;
  gzip_types text/plain text/xml image/svg+xml # text/html in core already.
    application/rss+xml application/atom+xml application/xhtml+xml
    text/css application/json application/x-javascript
    application/font-otf application/font-ttf;

  # Do not allow public access to private cache directory.
  if ($uri ~* /wp\-content/cache/comet\-cache/cache(?:/|$)) {
      return 403;
  }
  # Do not allow public access to private cache directory.
  if ($uri ~* /wp\-content/cache/comet\-cache/htmlc/private(?:/|$)) {
      return 403;
  }

  # ↓ See: http://davidwalsh.name/cdn-fonts
  # This prevents cross-domain security issues related to fonts.
  # Only needed if you use Static CDN Filters in Comet Cache.

  location ~* \.(?:ttf|ttc|otf|eot|woff|woff2|css|js)$ {
      add_header Access-Control-Allow-Origin *;
  }

  # ↓ This is optional, but suggested. It's a flag to tell Comet Cache
  # that you completed this Nginx configuration.

  location ~* \.php$ {
      fastcgi_param WP_NGINX_CONFIG done;
  }
}
未经允许不得转载:飞翔线 » wordpress的cache插件在nginx配置和测试
分享到:
赞(0)

网站改版支付功能未上线,请移步淘宝店!

等待