How to send proxy cache status to backend server?

Makailol Charls makailol7 at gmail.com
Thu Mar 20 04:08:40 UTC 2014


Hi,

Is there some way to achieve this? I want to pass requests to backend based
on cache status condition.

Thanks,
Makailol


On Wed, Mar 19, 2014 at 7:45 PM, Maxim Dounin <mdounin at mdounin.ru> wrote:

> Hello!
>
> On Wed, Mar 19, 2014 at 03:30:03PM +0530, Makailol Charls wrote:
>
> > One more thing I would like to know, would it be possible to proxy_pass
> > request conditionally based on $upstream_cache_status ?
> >
> > For example here we set request header with proxy_set_header Cache-Status
> > $upstream_cache_status; instead we can use condition like below,
> >
> > if ($upstream_cache_status = "BYPASS") {
> >     proxy_pass http://someIP;
> > }
> >
> > if ($upstream_cache_status = "MISS") {
> >     proxy_pass http://anotherIP;
> > }
> >
> > I tried this but could not find this working. I can set request header
> for
> > backend with proxy_set_header but can not use this variable
> conditionally.
>
> That's expected, as cache status isn't known at the rewrite phase
> when "if" directives are executed.  It's not even known if a
> request will be proxied at all.
>
> --
> Maxim Dounin
> http://nginx.org/
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20140320/9ea4bfd3/attachment.html>


More information about the nginx mailing list