Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excluding a specific URL from Varnish cache

I have a seemingly simple problem:

I need to exclude only the homepage from Varnish by modifying default.vcl.

I have tried the following syntax:

if (req.url == "http://www.test.com/") {
    return (pass);
}

-- with all the variations (trailing slashes etc.).

I feel like I am missing something simple/fundamental here... can anyone give me a hand?

like image 553
Matt Ogram Avatar asked Dec 20 '12 02:12

Matt Ogram


1 Answers

req.url holds the URL as per the http standards. This in your case is /. req.http.host is where the host is sent. It corresponds to the basic anatomy of a HTTP request. So your example would be written:

if (req.http.host == "www.test.com" && req.url == "/") {
    return (pass);
}
like image 93
Clarence Avatar answered Nov 15 '22 06:11

Clarence