Basically, I need ability to determine if request can be server from local cache or not before proxy_pass handler is executed.
Thanks,
Basically, I need ability to determine if request can be server from local cache or not before proxy_pass handler is executed.
proxy_cache_path /var/www/cache levels=1:2 keys_zone=my_cache:10m;If the response is available in the local cache, it'll just serve it from there, and if not, it'll automatically pull it down from the upstream.
upstream my_upstream {
server x.x.x.x:yy;
}
server {
location /my_location {
proxy_cache my_cache;
proxy_cache_key "$request_uri|$cookie_my_cookie_var"; # or whatever key you prefer
proxy_pass http://my_upstream/my_proxy_path;
}
}
location /my_location {
set $bypass_cache 0; # try local cache by default
rewrite_by_lua_block {
if coherence_has_response() then
# bypass local cache and retrieve from upstream, maybe coherence, or wherever
ngx.var.bypass_cache = 1
else
# try to serve the content from local cache first, before triggering an upstream request
ngx.var.bypass_cache = 0
end
}
proxy_cache my_cache;
proxy_cache_key "$request_uri|$cookie_my_cookie_var"; # or whatever key you prefer
proxy_pass http://my_upstream/my_proxy_path;
proxy_cache_bypass $bypass_cache;
}
--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
upstream memcached_backend {This will keep 32 memcached and 16 HTTP upstream connections running, which you can then access in your nginx config - and, IIUC, any *_by_lua* directives where the socket API is not disabled.
server 127.0.0.1:11211;
server 10.0.0.2:11211;
keepalive 32;
}
upstream http_backend {
server 127.0.0.1:8080;
keepalive 16;
}