为什么我的GAE上的wordpress网站没有被缓存?

时间:2014-02-09 23:28:56

标签: php wordpress google-app-engine caching memcached

我在GAE上安装了wordpress 3.8.1 - 从另一台主机上的WP-MU安装转移。我安装了GAE插件,但是提到我还应该安装batcache和memcached插件。所以我安装了它们但它们似乎没有工作 - 我在<head>部分没有调试输出,响应是200,站点通常很慢。我该怎么做才能启用缓存?以下是使用curl -i重新加载后的响应标头:

HTTP/1.1 200 OK
Vary: Cookie
X-Pingback: http://www.websiteinquestion.com/xmlrpc.php
Content-type: text/html; charset=UTF-8
Vary: Accept-Encoding
Date: Sun, 09 Feb 2014 23:20:32 GMT
Server: Google Frontend
Cache-Control: private
Alternate-Protocol: 80:quic,80:quic
Transfer-Encoding: chunked

启用时会有一些调试输出:

Notice: Undefined offset: 1 in /base/data/home/apps/s~xxx/xxx.stringofnumbers/wordpress/wp-content/object-cache.php on line 374

这是app.yaml

application: xxxxx
version: xxx
runtime: php
threadsafe: no
default_expiration: "2d"
api_version: 1
instance_class: F1
automatic_scaling:
  min_idle_instances: 0
  max_idle_instances: 1
  min_pending_latency: automatic
  max_pending_latency: 15000ms

在wp-config.php中我添加了

define('WP_CACHE', true);

我尝试在GAE控制台上查看memcache统计信息,但我无法在任何地方找到查看器。在设置中,memcache设置为共享模式。

2 个答案:

答案 0 :(得分:3)

就我而言,Google设计的batcache配置是问题的原因。在https://developers.google.com/appengine/articles/wordpress上给出的说明中,它说:

  

在wp-config.php文件中,在文件末尾添加以下行:

$batcache = [
  'seconds'=>0,
  'max_age'=>30*60, // 30 minutes
  'debug'=>false
];

如果你这样做,就会收到警告:

  

警告:call_user_func_array()期望参数1有效   回调,第一个数组成员不是有效的类名或对象   /Users/per/google-cloud/appocentric-wordpress/wordpress/wp-includes/plugin.php   在线199

但是,如果将batcache配置行移到读取行

之前
  

/ *就是这样,停止编辑!快乐的博客。 * /

在wp-config中,它有效!所以相信Wordpress的人而不是谷歌,在这种情况下......

===============

我还找到了您所描述的Undefined Offset问题的修复程序(来源http://wordpress.org/support/topic/fix-for-notice-undefined-offset-1)。

Memcached Memcached插件版本2.0.2给出了以下错误消息:

Notice: Undefined offset: 1 in /var/www/html/wp-content/object-cache.php on line 374

这是因为只将服务器列为没有端口的默认服务器:

array(1) { [0]=> string(9) "127.0.0.1" }

没有列出端口来填充第374行中的端口变量,从而导致未定义的偏移通知。这是第374行:

list ( $node, $port ) = explode(':', $server);

解决方案是修改第365行:

$buckets = array('127.0.0.1');

为:

$buckets = array('127.0.0.1:11211');

这已在源代码中修复,将在以后的版本中提供&gt; 2.0.2

答案 1 :(得分:0)

在管理中禁用 RSS小部件后,网站正在正确缓存。

相关问题