Score:0

cancel varnish cache so that it goes to the backend on the homepage only

kr flag
if (req.url == "/") {
  return(pass);
}

Does this allow us to cancel the varnish only on the homepage (ex: www.prism.com) and not other pages like www.prism.com/product?

I was thinking this would also work, but I am not sure, and is the above the better option?

if (req.url ~ "") {
  return(pass);
}

I just want it to skip caching on the homepage, because we're using it to set a cookie for all users. I need to modify the caching, because I realized some code for generating cookies didn't work during peak hours.

Score:1
in flag

The following code is indeed to right way to bypass the cache on the homepage:

if (req.url == "/") {
    return(pass);
}

However, please consider the impact of such an action. The homepage is the point of entry for the majority of your users. Not being able to cache it will have a severe impact on your performance.

The question is: what kind of cookie are you setting on the homepage?

  • Is this cookie really required?
  • Could to cookie be synthesized and created by Varnish instead?
  • Could the cookie be set by Javascript instead.

Please consider your options and try to look for a solution where your most important page is still cached.

As a side-effect, you'll need to write the necessary VCL to deal with the Cookie request header for incoming requests that are considered cacheable.

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.