Gourav gaur
Gourav gaur

Reputation: 13

Varnish cache only homepage first

I am new to varnish cache.i have a website xyz.com and i want cache homepage first only so how to start with varnish and how will the vcl file look like for homepage cache only.

Please help.

Upvotes: -1

Views: 212

Answers (1)

Thijs Feryn
Thijs Feryn

Reputation: 4808

Here's some basic VCL code that will cache the homepage explicitly and rely on the built-in VCL behavior for all other requests.

vcl 4.1;

backend default {
    .host = "127.0.0.1";
    .port = "8080";
}

sub vcl_recv {
    if((req.method == "GET" || req.method == "HEAD") && req.url == "/") {
        return(hash);
    }
}

Upvotes: 0

Related Questions