I have a feeling this is simple, but I'm having no luck figuring it out on my own.
I am storing full pages in memcache on the PHP side, and then checking for the memcache page in nginx and serving that up if found. Additionally, I'd like to skip the memcache check if the request is not GET and/or the user has an authentication cookie set. Any help is much appreciated. My (simplified) config:
server {
listen 80;
server foo.com;
.. various configs ..
location / {
rewrite ^/user/?$ /user.php last;
.. many more rewrites ..
}
location ~ \.php$ {
if ($request_method != GET) {
# what to put here to send to @cache_miss?
break;
}
if ($http_cookie ~* "cookie_authenticated" ) {
# what to put here to send to @cache_miss?
break;
}
set $memcached_key "foo:$request_uri";
memcached_pass 127.0.0.1:11211;
default_type text/html;
error_page 404 405 502 = @cache_miss;
}
location @cache_miss {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}
I've tried all sorts of variations with proxy_pass to upstreams, fastcgi_pass, etc. I'd like to just pass it to the named directive, but I'm not sure how to do that. (Or what the proper alternative would be.)
Thanks in advance.