Matt Ogram
Matt Ogram

Reputation: 111

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?

Upvotes: 5

Views: 15107

Answers (1)

Clarence
Clarence

Reputation: 2964

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);
}

Upvotes: 11

Related Questions