Nginx use memc

Hello!
Encountered in the use of memc such a problem, I do not know how to
solve. In the nginx configuration file and php file using memc, can be
normal cache. However, if the cache of php file include jump statement,
such as @header, then jump failure. How to solve this problem?
nginx.conf
server {

location ~ /async/(.*) {
set_md5 $md5
$host$request_uri;
set $memc_key $md5;
memc_pass memcbackend;
memc_flags_to_last_modified on;
memc_connect_timeout 30s;
memc_send_timeout 30s;
memc_read_timeout 30s;
access_log off;
expires max;
error_page 404 = /async/index.php?$query_string ;
}

}
php file /async/index.php

<?php $url = "http://www.baidu.com"; @header ( "HTTP/1.1 301 Moved Permanently" ); @header ( "Location: " . $url ); exit(); $m = new Memcached(); $m->addServer('192.168.3.101', 3000); $m->setOption(Memcached::OPT_COMPRESSION, false); $time = time(); $urlInfo = parse_url($_SERVER ['REQUEST_URI']); $key = $_SERVER ['SERVER_NAME'].$_SERVER ['REQUEST_URI']; echo $key; $m->set(md5($key), $time ,60); ?>

If the access address http://www.test.com/async/test.php
/async/ directory is not include test.phpd file, it will be 404
redirected to /async/ index.php, but the @header in /async/index.php
will not be effective.
How to solve this problem? Thank you very much!

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,215565,215565#msg-215565

On Thu, Sep 22, 2011 at 5:25 PM, lys0212 [email protected] wrote:

Hello!
Encountered in the use of memc such a problem, I do not know how to
solve. In the nginx configuration file and php file using memc, can be
normal cache. However, if the cache of php file include jump statement,
such as @header, then jump failure. How to solve this problem?

Please do not abuse the error_page directive with ngx_memc to do
response caching; it’s problematic. I suggest you take a look at the
ngx_srcache module which can serve as a generic cache layer and can be
used safely with backend storage modules like ngx_memc:

http://wiki.nginx.org/HttpSRCacheModule

Regards,
-agentzh

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs