Varnish folks,

I'm trying to combine Varnish with a Tomcat  servlet  to make a fancy reverse 
proxy.  The idea is that Varnish forwards a URL to the servlet, which uses a 
302 redirect to tell Varnish what the "real" URL should be.  For this to work 
well I need Varnish to do two things: 1) cache the 302 redirects from the 
servlet, and also 2) hide the redirect from the client.  It seems like I can 
get  Varnish to do one or the other, but not both simultaneously.

I'm using the following in default.vcl (which is more or less the approach 
described in http://www.gossamer-threads.com/lists/varnish/dev/15409):

sub vcl_fetch {
  if (beresp.status == 302) {
    set req.url = beresp.http.Location;
   restart;
  }
}

This works, and hides the redirect from the client, but doesn't cache the 302 
response.  I also tried this:

sub vcl_fetch {
  if (beresp.status == 302) {
    set req.url = beresp.http.Location;
   return(deliver);
  }
}

This also works, and caches the 302 response, but does not hide the 302 from 
the client.

I am guessing that vcl_deliver is the subroutine in which back-end responses 
get pushed into the cache, which means that if I hide the redirect by doing a 
restart, then I lose my chance to cache the 302 response.

Is this right?  Any suggestions as to how I can cache the 302 response and also 
hide the redirect from the client?

Jeff

_______________________________________________
varnish-misc mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Reply via email to