nginx use memc

lys0212 nginx-forum at nginx.us
Thu Sep 22 09:25:05 UTC 2011


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



More information about the nginx mailing list