我有一个简单的nginx配置;
server{
servername localhost;
root /var/www/webroot;
location / {
set_md5 $memcached_key $uri;
index index.php index.html;
try_files $uri $uri/ @cache;
}
location @cache {
memcached_pass localhost:11211;
default_type text/html;
error_page 404 @fallback;
}
location @fallback{
try_files $uri $uri/ /index.php?url=$uri&$args;
}
location ~ \.php${
fastcgi_param MEM_KEY $memcached_key;
include /etc/nginx/fastcgi.conf;
fastcgi_index index.php;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}
我有一个CakePHP助手,它使用MEM_KEY参数将视图保存到memcached中.我已经测试了它并且它正在工作,但是,nginx总是会进入@fallback方向.我该如何解决此问题?可能会出现问题吗?
最佳答案
感谢DukeLion的评论,我终于可以找到发生了什么,nginx正在进入memcached服务器okey,但是cakephp正在改变密钥.
例如,我尝试访问/home_page.html
Nginx使用/home_page.html进入内存缓存,不要找到它,因此加载cakephp,cakephp生成视图并将其保存在密钥_home__page_html中
解决方案是扩展memcached cakephp引擎.
谢谢!!!
pd:您可以在http://andy-gale.com/cakephp-view-memcache.html中获取memcached视图引擎的示例