Welcome! Log In Create A New Profile

Advanced

nginx use memc

September 22, 2011 05:25AM
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!
Subject Author Posted

nginx use memc

lys0212 September 22, 2011 05:25AM

Re: nginx use memc

agentzh September 22, 2011 05:46AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 86
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready