Score:0

Easiest Way to Temprarily Disable Varnish Cache (varnishadm)

cn flag

What is the easiest way to tell varnish:

Hey Varnish processes, please clear your cache. And also please don't cache anything at all right now. I want you to just pass all requests straight to the backend for now. I'll let you know when I want you to go back to normal operation in a bit.

I'm doing some debugging and iterating on a website, but I'm tired of constantly clearing my cache with this command between every change & new request.

varnishadm 'ban req.url ~ "."'

Also, this is a fairly complex varnish config that has many backends for many distinct websites & domains.

I just want the simplest command that will tell varnish to temporarily force all requests to the backend.

# this command does not exist
varnishadm 'caching-pause req.url ~ "."'

And the corresponding simple command to restore varnish back to normal operation.

# this command also does not exist
varnishadm 'caching-resume req.url ~ "."'

Is there some easy way to tell varnish to temporarily stop caching everything?

Score:1
in flag

Ensure the following VCL code is in /etc/varnish/no-cache.vcl:

vcl 4.0;

backend default {
    .host = "your-host";
    .port = "your-port";
}

sub vcl_recv {
    return(pass);
}

Then load the VCL as follows:

varnishadm vcl.load nocache /etc/varnish/no-cache.vcl

Whenever you want Varnish to bypass the cache, run the following command:

varnishadm vcl.use nocache

If you want to go back to normal operations and your regular VCL is named boot, just use the following command:

varnishadm vcl.use boot

You can use varnishadm vcl.list to see the list of loaded VCL files and to see which one is active.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.