Score:0

varnish cache not working for ajax calls

dk flag
if (req.url ~ "do_ajax.php" && req.request == "GET") {
      return (lookup);
}

I put this line inside the varnish.vcl config, but I get this header in the response header:

no-cache, must-revalidate, max-age=0

I also tried with:

if (req.url ~ "do_ajax.php" && req.request == "GET") {
      return (hash);
}

But varnish fails to restart unless I remove return (hash).

Now, I am wondering if there's a line in the varnish config file that forces all ajax calls to not accept cache, and the second thing I don't understand is why I am getting it in the response header, shouldn't it be the client that sends this in the request header instead? Why is the server returning this?

Score:0
in flag

As mentioned in one of the other posts you made: you are probably using an outdated version of Varnish. That may explain why the VCL syntax is not working.

Please make sure you're on Varnish 6 or Varnish 7. See https://www.varnish-software.com/developers/downloads/#linux-packages for a list of install procedures depending on the Linux distribution you are using.

I also provided a VCL solution in one of the other posts you made.

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.