The requirement is:
When a cookie exist, not return cached file and not cache the response, if the cookie not exist, return cached file and . cache the response.
In the past, we use a standalone cacheserver, the configuration looks like below:
location / {
if ($http_cookie ~* xxx ) {
set $cache 0;
}
if ($cache = 1) {
proxy_pass http://cacheserver;
break;
}
location ~* \.php {
fastcgi_pass 127.0.0.1:8080;
}
So, cookie-non-exist visit will be directed to cacheserver, and cookie-exist visit will be directed to fastcgi_pass.
So if we want to remove the cacheserver, and use nginx's cache feature, we need to configure like this:
location ~* \.php {
fastcgi_pass 127.0.0.1:8080;
fastcgi_cache php;
fastcgi_cache_key $request_uri;
}
Then how can we set cookie-non-exist visits to use cache and cookie-exist visit not to use cache?
Edited 1 time(s). Last edit at 06/20/2009 06:56AM by tonyy.