配置:
location ~* ^/(pic|ap|tmp|img|glogo|mix).*\.(jpg|png|jpeg|gif)$ {
charset utf-8;
default_type text/html;
#srcache-nginx-module
set $key '$uri';
#set $key '/img/_o/44/56/8e99bbe907d20d1f7f687993b543_200_200.jpg';
#set_md5 $key $uri;
srcache_fetch GET /memc $key;
srcache_store PUT /memc $key;
rewrite ^/(.*?)$ /index.php break;
root /home/lichaowang/service/image_webroot/program;
fastcgi_pass fastcgi;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
请求:http://127.0.0.1:8080/pic/r/9f/19/f2723a951f08b38a468ddad30221_481_768.jpg
nginx的debug的日志:
2013/02/03 20:05:06 [debug] 4226#0: *4 http script set $key
2013/02/03 20:05:06 [debug] 4226#0: *4 http script set $memc_key
2013/02/03 20:05:06 [debug] 4226#0: *4 http output filter "/memc?/pic/r/9f/19/f2723a951f08b38a468ddad30221_481_768.jpg"
2013/02/03 20:05:06 [debug] 4226#0: *4 http output filter "/memc?/pic/r/9f/19/f2723a951f08b38a468ddad30221_481_768.jpg"
2013/02/03 20:05:06 [debug] 4226#0: *4 http output filter "/memc?/pic/r/9f/19/f2723a951f08b38a468ddad30221_481_768.jpg"
2013/02/03 20:05:06 [debug] 4226#0: *4 http output filter "/memc?/pic/r/9f/19/f2723a951f08b38a468ddad30221_481_768.jpg"
2013/02/03 20:05:06 [debug] 4226#0: *4 http output filter "/memc?/pic/r/9f/19/f2723a951f08b38a468ddad30221_481_768.jpg"
2013/02/03 20:05:06 [debug] 4226#0: *4 http output filter "/memc?/pic/r/9f/19/f2723a951f08b38a468ddad30221_481_768.jpg"
2013/02/03 20:05:06 [debug] 4226#0: *4 http output filter "/memc?/pic/r/9f/19/f2723a951f08b38a468ddad30221_481_768.jpg"
2013/02/03 20:05:06 [debug] 4226#0: *4 http output filter "/index.php?"
在 2013年2月2日星期六UTC+8上午9时52分32秒,agentzh写道:
Hello!
On Fri, Feb 1, 2013 at 4:53 PM, Lichao Wang wrote:
>
> 在使用srcache过程中遇到的cache命中的情况下继续访问后端fastcig服务情况,具体情况是通过
> set $key '$uri';
> srcache_fetch GET /memc $key;
> srcache_store PUT /memc $key;
> 写入cache一个key后再次访问的时候虽然memcached中已经存在这个key的value但是还是会调用upstream的fastcgi去处理。
请提供问题请求相对应的 Nginx 调试日志,见这里的文档:
http://wiki.nginx.org/HttpSRCacheModule#Trouble_Shooting
Best regards,
-agentzh