Changing the fetch for virtual hosts.

Per Buer perbu at varnish-software.com
Fri Feb 4 10:04:01 CET 2011


Hi Chris,

On Thu, Feb 3, 2011 at 9:42 PM, Chris Johnson
<johnson at nmr.mgh.harvard.edu> wrote:
>     IF (big IF) I'm reading things right here, it looks like I can
> rewrite the host name in vcl_recv after the request is received but
> before the fetch.  If I do this in vcl_recv;
>
> if (req.http.host ~ "^old.host.edu") {
> set req.http.host = "new.host.edu";
> }
>
> will the request go to the new host?

Not unless you explicitly set the backend later. The only thing you do
here is to set a new Host: header, which makes sense, btw.

> The idea is to stop varnish from basically cache everything twice since
> both new.host and old.host point to the same set of pages.
> I don't want varnish doing double duty
> here.  All varish knows is that the URLs are different and if I
> understand correctly will treat them as different sets of pages
> caching both.

You assume correctly. The default is that varnish uses the Host and
the URL as key, you can check out the vcl_hash subroutine in the
default VCL.



-- 
Per Buer, Varnish Software
Phone: +47 21 98 92 61 / Mobile: +47 958 39 117 / Skype: per.buer
Varnish makes websites fly!
Want to learn more about Varnish? http://www.varnish-software.com/whitepapers




More information about the varnish-misc mailing list