In my environment, port numbers may be on the request, but are not needed to
respond nor should they influence the cache. In my vcl_recv, I have the
following lines:
/* determine vhost name w/out port number */
set req.http.newhost = regsub(req.http.host, "([^:]*)(:.*)?$", "\1");
set req.http.host = req.http.newhost;
This strips off the port number from the host name in the request. Doing it
this way, the port number is discarded and NOT passed on to the application.
It is also not present when creating and looking up hash entries.
If you require the port number at the application level, you will have to do
something a bit different to preserve it.
Jim
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Shenton, Chris
(HQ-LM020)[INDYNE INC]
Sent: Monday, March 07, 2011 4:37 PM
To: [email protected]
Subject: varnishd -a addr:8001,addr:8002 -- Share same cache?
To accommodate our hosting environment, we need to run varnish on two different
ports, but we want to make both use the same cache. That is, if I have:
varnishd -a 127.0.0.1:8001,127.0.0.1:8002
I want client requests to both both 8001 and 8002 ports to share the content of
the same cache. So if one client hits :8002 with a URL and another later hits
:8001 with the same URL, I want the latter to retrieve the content cached by
the former request.
In my testing, however, it seems that this is not happening, that the doc is
getting cached once per varnishd port.
First on 8001, we see it's not from cache as this is the first request:
> $ curl -v -o /dev/null http://localhost:8001/ 2>&1 | grep X-Varnish:
> < X-Varnish: 730421263
Then to 8002 where I'd hope it was returned from cache, but the X-Varnish and
Age headers indicate it's not:
> $ curl -v -o /dev/null http://localhost:8002/ 2>&1 | grep X-Varnish:
> < X-Varnish: 730421264
Now back to the first port, 8001, and we see it is in fact returned from cache:
> $ curl -v -o /dev/null http://localhost:8001/ 2>&1 | grep X-Varnish:
> < X-Varnish: 730421265 730421263
And if I try 8002 again, it's also returned from cache:
> $ curl -v -o /dev/null http://localhost:8002/ 2>&1 | grep X-Varnish:
> < X-Varnish: 730421266 730421264
Is there a way to make both ports share the same hash? I'm guessing the
listening port is included with the hash key so that's why it appears each URL
is being stored separately. If so, is there a way to remove the listening port
from the hash key the document is stored under? Or would that even work?
Thanks.
_______________________________________________
varnish-misc mailing list
[email protected]
http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
_______________________________________________
varnish-misc mailing list
[email protected]
http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc